Welcome to the Treehouse Community
Looking to learn something new?
José Eduardo Eguiguren17,555 Points
Save a high score for an Android game even after closing the activity or app
I need to store a value somehow permanently to keep the player's highscore. I've seen people used SharedPreferences:
SharedPreferences prefs = this.getSharedPreferences("myPrefsKey", Context.MODE_PRIVATE); Editor editor = prefs.edit(); editor.putInt("key", score); editor.commit();
However I do not understand exactly how to store the value there and after doing so, how am i supposed to get it back when I need it?
Thank you in advance.