I have created a class that extends Application to store variables I want to access from multiple activities
public class MyApplication extends Application
{
private String fbId, firstName;
private long expires;
@Override
public void onCreate()
{
super.onCreate();
}
public String getFbId()
{
return fbId;
}
public void setFbId(String fbId)
{
this.fbId = fbId;
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
I am able to access these variables and set these variables the first time I am running the app. Once I quit out and restart the application it sets my values to null, any suggestions for why this may be happening?
If you don’t store your data in storage (that doesn’t need to be a database, could be a flat file, SharedPreferences, or whatever) then it is not persistent.
You should be using
SharedPreferencesto save this kind of persistent data.