Skip to content

Instantly share code, notes, and snippets.

@dynoChris
Last active February 6, 2020 18:14
Show Gist options
  • Save dynoChris/e30024e8d697ff425ad8442578065c0a to your computer and use it in GitHub Desktop.
Save dynoChris/e30024e8d697ff425ad8442578065c0a to your computer and use it in GitHub Desktop.
Work with SharedPreferences in Android
//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