Skip to content

Instantly share code, notes, and snippets.

@drulabs
Created August 7, 2018 19:09
Show Gist options
  • Save drulabs/7fe102e27c9168c5c5783dce7d9ef6c6 to your computer and use it in GitHub Desktop.
Save drulabs/7fe102e27c9168c5c5783dce7d9ef6c6 to your computer and use it in GitHub Desktop.
import android.content.Context
import android.content.SharedPreferences
private fun doSomething(context: Context) {
val prefs = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE).edit()
prefs.persist(key = "my_name", value = "Kaushal Dhruw")
}
fun SharedPreferences.Editor.persist(key: String, value: String) {
putString(key, value)
apply()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment