Ensure that an object is stored in the database before the app is killed (Android)
I have an Integer[] in Android. I need to sav开发者_JAVA技巧e it persistently in a table of my database but can´t save it with each change because it changes constantly while the application is beeing used and I'll suppouse a high overhead.
I have decided that update the table once every 20 minutes is ok but I need to ensure that the last change is saved even if the user kills the app with a task killer at the minute 22 for example
How can I do it?
Thanks in advance
If your app is Force Closed, there's no way for you to run code from the dying app. But you could override the onPause method in Activity if you want to save your data when your app looses focus.
精彩评论