I have 2 activity say for e.g MainActivity and PlayActivity. I am retrieving value of currentLevel from SharedPreferences in MainActivity using following code.
sharedPreferences= PreferenceManager.getDefaultSharedPreferences(this);
// comment this to see if value is saved or not
currentLevel=sharedPreferences.getInt("currentlevel",1);
and I am Updating value of currentLevel in PlayActivity using following code.
sharedPreferences= PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("currentlevel",currentLevel+1);
editor.apply();
Now my problem is while running app i am not able to update its value. For e.g while i am in PlayActivity and i won a level and i updated value of Shared Preference but while running app if i go back to MainActivity and try to retrieve CurrentLevel value, i got previous value not updated one. Please Help. One more thing if i push updated of my app in future will sharedPrefrence also get updated with default 1 value or it will retain its previous value.