Reputation: 428
I have this class, and i want to use its methods in my main activity, how can i create an instance?
public class BDD {
...
public boolean insertarGuia(String g, String d) {
...
}
}
Upvotes: 1
Views: 44167
Reputation: 107
It's very easy, just create an object of your class and call any of the method in your activity:
BDD obj = new BDD();
obj.ArregloGuias();
Upvotes: -1
Reputation: 1366
Create an instance of that class with the 'new' keyword in your main activity and then invoke those methods on that object.
BDD bdd = new BDD();
boolean value = bdd.insertarGuia("foo", "bar");
Or make the methods static
Change
public boolean insertarGuia(String g, String d) {
to
public static boolean insertarGuia(String g, String d) {
and in your main method have
boolean value = BDD.insertaGuia("foo", "bar");
Upvotes: 2