Basically I have a list and I need to remember the offset and load the offset value every time the Activity is restored unless the Activity completely destroyed.
//Inside onCreate
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
Offset = settings.getInt("TheOffset", 0);
//End onCreate
@Override
protected void onPause() {
super.onPause();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("TheOffset", Offset);
}
@Override
protected void onStop() {
super.onStop();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("TheOffset", Offset);
}
@Override
protected void onDestroy() {
super.onDestroy();
//settings.getInt("TheOffset", 0);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("TheOffset", 0);
}