Skip to content

Instantly share code, notes, and snippets.

@srikrishnasakunia
Created December 29, 2022 12:24
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 srikrishnasakunia/5dfaa0460be473127e690b91542358a6 to your computer and use it in GitHub Desktop.
Save srikrishnasakunia/5dfaa0460be473127e690b91542358a6 to your computer and use it in GitHub Desktop.
Main Activity KT
// Retriving Using the Flow Method
lifecycleScope.launch {
preferenceDataStoreHelper.getPreference(NAME_KEY,"").collect {
name = it
}
}
// Retriving Using the Not Flow / static data Method
lifecycleScope.launch {
val name = preferenceDataStoreHelper.getFirstPreference(NAME_KEY,"")
}
// Setting Data
val name = "Android Developer"
lifecycleScope.launch {
preferenceDataStoreHelper.putPreference(NAME_KEY,name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment