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