in the onDestroy() method of an activity i want to set some SharedPreferences to the initial value. About a month ago or so this worked. So when the User shuts down the app by clicking the button next to the home button and closing it (don't know how else to describe it) onDestroy() was called and the values were saved - i want them to be saved only when the app is closed totally.
any ideas why this does not work anymore or what to do to solve it?
thank you!
public void onDestroy() {
super.onDestroy();
if(isFinishing()) {
SharedPreferences gpsPref = getSharedPreferences(getString(R.string.preferences_no_gps), Context.MODE_PRIVATE);
SharedPreferences.Editor editorGps = gpsPref.edit();
editorGps.putString(getString(R.string.saved_no_gps), "0");
editorGps.commit();
SharedPreferences visibilityPref = getSharedPreferences(getString(R.string.preferences_visibility), Context.MODE_PRIVATE);
SharedPreferences.Editor editorVisibility = visibilityPref.edit();
editorVisibility.putString(getString(R.string.saved_visibility), "123");
editorVisibility.commit();
}
}
by the way it makes no difference if i put code into if clause or not.