Reputation: 7949
My app has a class that extends Application
and another class which is an API to get data from the Internet using a singleton pattern.
When the Application
class loads, onCreate()
will instantiate the singleton to be used throughout the app.
At a certain point, the user my request a transportation route, which will cause Maps to load and send my app to background.
If the user return to the app soon enough (ie, the app hasn't been fully terminated yet), all the static variables from the singleton are now null
.
What is the proper way to save those variables before going to background and retrieve them back after returning to foreground?
Upvotes: 0
Views: 111
Reputation: 9569
Take a look on SharedPreferences. Use it in onPause
method of activity.
Upvotes: 1