Created
January 25, 2018 01:51
-
-
Save aasumitro/c23df0cd9a339c9a4672c0fa258ba1cb to your computer and use it in GitHub Desktop.
Kotlin Preferences Test
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
class PrefsUtil @Inject constructor(private val sharedPreferences: SharedPreferences) { | |
fun putBoolean(key: String, value: Boolean): Boolean { | |
val editor: SharedPreferences.Editor = sharedPreferences.edit() | |
editor.putBoolean(key, value) | |
return editor.commit() | |
} | |
fun getBoolean(key: String, defaultValue: Boolean): Boolean = | |
sharedPreferences.getBoolean(key, defaultValue) | |
fun clearPrefs() = sharedPreferences.edit().clear().clear().apply() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment