During one of my app development, I had the similar issue where app have single activity and need to save some state values (usually string, Boolean) onpause. I will give you idea how i handle it, and I hope it will useful to you also.
protected void onPause() {
super.onPause();
saveState();
}
protected void onResume() {
super.onResume();
retrieveState();
}
donot forget focus change ...
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus) {
retrieveState();
}
else { saveState(); }
}
Now the save and retrieve data
public void saveState()
{
SharedPreferences settings = getSharedPreferences(WEBSTATE, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(CURRENT_URL_STATE, "some url");
editor.putInt(FILECOUNT, 10);
/* any other content... */
editor.commit();
}
public void retrieveState()
{
SharedPreferences settings = getSharedPreferences(WEBSTATE, 0);
String current_url = settings.getString(CURRENT_URL_STATE, "");
int count = settings.getInt((FILECOUNT, 0);
/*use these value as per requier.. */
}