开发者

Ensure that an object is stored in the database before the app is killed (Android)

开发者 https://www.devze.com 2023-03-26 15:23 出处:网络
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 beein

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消