Last active
May 31, 2019 13:11
-
-
Save PiotrPrus/50f56cac94bb88bb31291ac17754112c to your computer and use it in GitHub Desktop.
koin module with multiple shared preferences
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
val preferencesModule = module { | |
single(named("settingsPrefs")) { provideSettingsPreferences(androidApplication()) } | |
single(named("securePrefs")) { provideSecurePreferences(androidApplication()) } | |
} | |
private const val PREFERENCES_FILE_KEY = "com.example.settings_preferences" | |
private const val SECURE_PREFS_FILE_KEY = "com.example.secure_preferences" | |
private fun provideSettingsPreferences(app: Application): SharedPreferences = | |
app.getSharedPreferences(PREFERENCES_FILE_KEY, Context.MODE_PRIVATE) | |
private fun provideSecurePreferences(app: Application): SharedPreferences = | |
app.getSharedPreferences(SECURE_PREFS_FILE_KEY, Context.MODE_PRIVATE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment