The Android Developers documentation is an excellent place to start with any question like this. SharedPreferences
can be found here. SharedPreferences
is a simple Key-Value pair storage, so if you put an int into your shared preferences as with the key “high score”, then in the future, if you want to get that int, you need to use prefs.getInt("high score")
. It doesn’t matter what you name your keys, but it is generally good practice to use private static final string variables to store keys you will use on a regular basis.
0
solved Shared Preferences saving an int?