Skip to content
Advertisement

Android Call a method from another class

I know that this Question is repeated but I can’t find the answer in the Internet.

I want to call a method from another class.

I have Class1 and Class2.

In Class 2 I have this method:

JavaScript

I want to call the above method from Class1.

Thanks for any answer.

—-EDIT—-

JavaScript

—-LogCat—

JavaScript

Advertisement

Answer

You should use the following code :

JavaScript

In case you don’t want to create a new instance to call the method, you can decalre the method as static and then you can just call Class2.UpdateEmployee().

Advertisement