This file contains hidden or 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
inline val Context.sharedPreferences: SharedPreferences | |
get() = PreferenceManager.getDefaultSharedPreferences(this) | |
inline fun <reified T> SharedPreferences.get(key: String, defaultValue: T): T { | |
return when (T::class) { | |
Boolean::class -> this.getBoolean(key, defaultValue as Boolean) as T | |
Float::class -> this.getFloat(key, defaultValue as Float) as T | |
Int::class -> this.getInt(key, defaultValue as Int) as T | |
Long::class -> this.getLong(key, defaultValue as Long) as T | |
String::class -> this.getString(key, defaultValue as String) as T |