I want to access a variable anywhere in the android app, even if I never open to view the Activity class that the variable is declared in. Is a static variable possible to use for this. and if i move around between different activities can i access this variable to modify and change it without losing the changes?
i understand that shared preferences and sqlite database can be used to store variable for this purpose, however I wanted to know if I can safely use a static for this. my only worry is if for some reason while the app is still being used that the static variable will be garbage collected while the app is open and in use.
also i did not want to make a Application class global variable, instead i wanted to know about just using a static variable in a one of java or android class of the app.