Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created July 4, 2022 12:14
Show Gist options
  • Select an option

  • Save wajahatkarim3/9929606b5220e23478fcc8af88ea256d to your computer and use it in GitHub Desktop.

Select an option

Save wajahatkarim3/9929606b5220e23478fcc8af88ea256d to your computer and use it in GitHub Desktop.
val preferences = this.getSharedPreferences("SOME_NAME", Context.MODE_PRIVATE)
// Reading the values from Preferences
val myStr = preferences.getString("myStrKey", "DEFAULT_STR")
val myLong = preferences.getLong("myLongKey", 0)
val myInt = preferences.getInt("myIntKey", 1)
val myDouble = preferences.getDouble("myDoubleKey", 0.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment