Skip to content

Instantly share code, notes, and snippets.

@raghunandankavi2010
Created August 18, 2020 06:35
Show Gist options
  • Save raghunandankavi2010/2b051c5d7c78932c869e1e6ba31ecf53 to your computer and use it in GitHub Desktop.
Save raghunandankavi2010/2b051c5d7c78932c869e1e6ba31ecf53 to your computer and use it in GitHub Desktop.
SharedPreferences edit inline function
// SharedPreferences extension function
// SharedPreferences.Editor.() - lambda with receiver
// call edit for the editor
// perform the action and apply edit.
inline fun SharedPreferences.edit(action: Sharedpreferenes.Editor.()->Unit) {
val edit = edit()
action.edit()
edit.apply()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment