Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created July 4, 2022 12:15
Show Gist options
  • Save wajahatkarim3/77dd770de8d625165b257c3079d3dab0 to your computer and use it in GitHub Desktop.
Save wajahatkarim3/77dd770de8d625165b257c3079d3dab0 to your computer and use it in GitHub Desktop.
val preferences = this.getSharedPreferences("SOME_NAME", Context.MODE_PRIVATE)
// Get the Editor of SharedPreferences
val editor = preferences.edit()
// Save values through put*() methods
editor.putString("myStrKey", “Some String Value Goes Here”)
editor.putLong("myLongKey", 12L)
editor.putInt("myIntKey", 10)
editor.putDouble("myDoubleKey", 2.0)
// Save the above values in Preferences
editor.apply()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment