Skip to content

Instantly share code, notes, and snippets.

@krupalshah
Created June 4, 2017 19:37
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 krupalshah/fc758c054c3042d66a703cc6896d75ee to your computer and use it in GitHub Desktop.
Save krupalshah/fc758c054c3042d66a703cc6896d75ee to your computer and use it in GitHub Desktop.
helper for shared prefs - kotlin version - usage after refactoring step 4
class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val prefs = PreferenceHelper.defaultPrefs(this)
//put value in prefs
prefs.setValue(Consts.SharedPrefs.KEY,"any_type_of_value")
//get value from prefs
val value:String? = prefs.getValue(Consts.SharedPrefs.KEY)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment