0

I have an Integer[] in Android. I need to save 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

Addev
  • 31,819
  • 51
  • 183
  • 302
  • Not an exact duplicate but you would be well served here: http://stackoverflow.com/questions/3511741/android-application-on-exit-event – Rob Allen Aug 09 '11 at 02:00

1 Answers1

0

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.

Klox
  • 931
  • 12
  • 21
  • I would override onPause(). Also, don't override onDestroy(), I think you cant guarantee data will be saved. –  Aug 09 '11 at 04:39