Created
July 4, 2022 12:21
-
-
Save wajahatkarim3/059baf1a4b3a279a0771630bcb8a0ee7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the DataStore object | |
private val settingsDataStore by preferencesDataStore(name = “app_settings”) | |
// Get the keys | |
val myStrKey = stringPreferencesKey("myStrKey") | |
// Read the values through coroutine scopes | |
lifecycleScope.launch { | |
settingsDataStore.data.map { pref -> | |
// Read the values here | |
val myStr = pref[myStrKey] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment