Post date: Mar 26, 2011 1:26:26 AM
So for weeks I couldn't figure out why when i was testing BACula on my phone (moto droid 1), the information persisted between application switching while on my girlfriend's phone (htc incredible) it seemed to forget all of my variables (being stored in SharedPrefs) 50% of the time. Turns out it was because of how we used our phones. When I left the app, I would do it by hitting the home button, or long-pressing home to switch apps. She, on the other hand, left the app by clicking the back button. Apparently, the back button throws away the SavedInstanceState. So, when she re-entered the app, and it checked for a SavedInstanceState, it found it to be null and thus reinitialized all the variables. My solution was to change my conditional in the onCreate to not check for SavedInstanceState==null, but to pull call a getInt from my SharedPrefs and check whether it returned the default value (which was one that I the user could not select). Anyway, it worked.
Lesson Learned: Leaving the Activity (App) using the Back button discards the SavedInstanceState.