please tell me what is the right way for maintaining the application state/data.
i have an alarm activity that perform alarm tasks. it takes user preferences and save them in global variables and start working in background.
when alarm invoked i called this activity again but when it start, it re-initialized all user preferences to their initial values.
how to maintain these values so when application comes to foreground it maintain its all values as it is?
If you have not soo much preferences, they could be maintained in shared prefrerences. I developed small library, which easies use of them. See example (in constructor):
https://github.com/ko5tik/camerawatch/blob/master/src/de/pribluda/android/camerawatch/Configuration.java
Rule of Thumb: load in onCreate() and save in onPause()
And library is here:
https://github.com/ko5tik/andject