Right now I am trying to save a variable when i close the app and get the variable back when i open the app back up. I have no idea if I'm doing this right. My variable is called count and would like to save and restore it. Is this right? If so, why isn't it working? If not, what do i need to change? (i'm obviously using SharedPreferences)
protected void onPause(){
super.onPause();
SharedPreferences settings = getSharedPreferences(PREFS_COUNT, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("count", count);
editor.commit();
}
@Override
protected void onResume(){
super.onResume();
SharedPreferences settings = getSharedPreferences(PREFS_COUNT, 0);
count = settings.getInt("count", count);
}