Android, Jetpack, Jetpack Datastore.
userPreferencesStore by single { context -> context.createDataStore(UserPreferencesSerializer, "user_preferences.pb") } } // In your feature module's ViewModel class MyViewModel(private val userPreferencesStore: DataStore<UserPreferences>) : ViewModel() { suspend fun getUsername() =