Last active
January 4, 2021 10:19
-
-
Save recoverrelax/9a3284150cfbd3ac08be4a204d6b60b8 to your computer and use it in GitHub Desktop.
Base SharedPreferences usage for Kotlin (with dagger2 bonus)
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 PrefsApp( | |
preferences: SharedPreferences, | |
moshi: Moshi | |
): BaseSharedPreferences(preferences, moshi) { | |
private val FIRST_RUN = "FIRST_RUN" | |
private val USER_DEVICE_ID = "USER_DEVICE_ID" | |
private val REALM_KEY = "REALM_KEY" | |
private val PREFS_KEY = "PREFS_KEY" | |
var firstRun: Boolean | |
get() = get(FIRST_RUN, true) | |
set(value) = put(FIRST_RUN, value) | |
var realmKey: String | |
get() = get(REALM_KEY, Prefs.PREF_DEF_STRING) | |
set(value) = put(REALM_KEY, value) | |
var prefsKey: String | |
get() = get(PREFS_KEY, Prefs.PREF_DEF_STRING) | |
set(value) = put(PREFS_KEY, value) | |
var deviceId: String | |
get() = get(USER_DEVICE_ID, Prefs.PREF_DEF_STRING) | |
set(value) = put(USER_DEVICE_ID, value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where is moshi.toJson ?