Created
December 27, 2021 11:13
-
-
Save agustarc/44d27dc54598fc587b10495bace97fa8 to your computer and use it in GitHub Desktop.
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
companion object { | |
private const val PREF_NAME = "example_pref" | |
private val EXAMPLE_DATA1 = stringPreferencesKey("exampleData1") | |
private val EXAMPLE_DATA2 = booleanPreferencesKey("exampleData2") | |
private val EXAMPLE_DATA3 = intPreferencesKey("exampleData3") | |
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore( | |
name = PREF_NAME, | |
produceMigrations = { context -> | |
listOf(SharedPreferencesMigration(context, PREF_NAME, setOf(EXAMPLE_DATA1.name, EXAMPLE_DATA3.name))) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment