Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created July 4, 2022 12:20
Show Gist options
  • Save wajahatkarim3/a1ab22e3972e402ca2ebb16d89a62682 to your computer and use it in GitHub Desktop.
Save wajahatkarim3/a1ab22e3972e402ca2ebb16d89a62682 to your computer and use it in GitHub Desktop.
// Get the DataStore object
private val settingsDataStore by preferencesDataStore(name = “app_settings”)
// Get the keys
val myStrKey = stringPreferencesKey("myStrKey")
// Write the values through coroutine scopes
lifecycleScope.launch {
settingsDataStore.edit { pref ->
// Write the values here
pref[myStrKey] = “SOME VALUE TO WRITE HERE”
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment