Issue
I have my app data centralized in the Application Class. A singleton class that all Activities refer to when they need data (The data are already up in memory and saved in an ArrayList in Application class). The problem is that when my app goes in Background the Application is destroyed and all the data are lost, If the data were in an Activity I could override onPause()
and save the data there in sharedPreferences but now the data are currently in Application, which as I understand doesn't allow me to override an onPause()
callback method. So what can I do ?
Solution
Create a method saveData() in your singleton and then call it in the activity onPause().
Activity class dont have methods such onDestroy() and onPause().
Answered By - f.old
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.