Last active
February 6, 2020 18:14
-
-
Save dynoChris/e30024e8d697ff425ad8442578065c0a to your computer and use it in GitHub Desktop.
Work with SharedPreferences in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//put | |
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | |
SharedPreferences.Editor editor = sharedPreferences.edit(); | |
editor.putInt("tag_number", 10); | |
editor.apply(); | |
//get | |
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); | |
int x = sharedPreferences.getInt("tag_number", 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment