Skip to content

Instantly share code, notes, and snippets.

@manuelernesto
Created June 1, 2020 20:10
Show Gist options
  • Save manuelernesto/bd24d362a8c5e9f89935823e3f4da455 to your computer and use it in GitHub Desktop.
Save manuelernesto/bd24d362a8c5e9f89935823e3f4da455 to your computer and use it in GitHub Desktop.
class MyPreferences(context: Context?) {
companion object {
private const val DARK_STATUS = "io.github.manuelernesto.DARK_STATUS"
}
private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
var darkMode = preferences.getInt(DARK_STATUS, 0)
set(value) = preferences.edit().putInt(DARK_STATUS, value).apply()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment