Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created July 20, 2022 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wajahatkarim3/9ae005143a39c1a102badcbe2aa6a0ae to your computer and use it in GitHub Desktop.
Save wajahatkarim3/9ae005143a39c1a102badcbe2aa6a0ae to your computer and use it in GitHub Desktop.
val preferences = getSharedPreferences("normal_prefs", MODE_PRIVATE)
// Storing Data in Preferences
with(preferences.edit()) {
putBoolean("Bool", true)
putString("String", "Some normal string value")
putInt("Integer", 10)
commit()
}
// Reading data from Preferences
val boolValue = preferences.getBoolean("Bool", false)
val strValue = preferences.getString("String", "")
val intValue = preferences.getInt("Integer", 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment