Skip to content

Instantly share code, notes, and snippets.

@egorikftp
Created Aug 22, 2021
Embed
What would you like to do?
enum class Theme(val storageKey: String) {
LIGHT("light"),
DARK("dark"),
SYSTEM("system")
}
private val prefs: SharedPreferences =
context.getSharedPreferences("PREFERENCES_NAME", Context.MODE_PRIVATE)
var theme by StringPreference(
preferences = prefs,
name = "pref_dark_mode",
defaultValue = SYSTEM.storageKey
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment