If your Android application contains two or more activities you may need to store global variables that can be accessed from any activity.
Create a new class inherited from Application class and create your global variables in it.
Now we have to specify the name of the class in AndroidManifest.xml file:
We can reference to the global variables in the code of Activities as follows:
We can also create methods in MyApplication class, they can be accessed the same way.