pull/1835/head
parent
da269c384a
commit
bb1ddba35b
@ -1,11 +1,57 @@ |
||||
@file:Suppress("unused") |
||||
|
||||
package io.legado.app.utils |
||||
|
||||
import android.content.SharedPreferences |
||||
import androidx.core.content.edit |
||||
|
||||
|
||||
fun SharedPreferences.getString(key: String): String? { |
||||
return getString(key, null) |
||||
} |
||||
|
||||
fun SharedPreferences.putString(key: String, value: String) { |
||||
edit { |
||||
putString(key, value) |
||||
} |
||||
} |
||||
|
||||
fun SharedPreferences.getBoolean(key: String): Boolean { |
||||
return getBoolean(key, false) |
||||
} |
||||
|
||||
fun SharedPreferences.putBoolean(key: String, value: Boolean) { |
||||
edit { |
||||
putBoolean(key, value) |
||||
} |
||||
} |
||||
|
||||
fun SharedPreferences.getInt(key: String): Int { |
||||
return getInt(key, 0) |
||||
} |
||||
|
||||
fun SharedPreferences.putInt(key: String, value: Int) { |
||||
edit { |
||||
putInt(key, value) |
||||
} |
||||
} |
||||
|
||||
fun SharedPreferences.getLong(key: String): Long { |
||||
return getLong(key, 0) |
||||
} |
||||
|
||||
fun SharedPreferences.putLong(key: String, value: Long) { |
||||
edit { |
||||
putLong(key, value) |
||||
} |
||||
} |
||||
|
||||
fun SharedPreferences.getFloat(key: String): Float { |
||||
return getFloat(key, 0f) |
||||
} |
||||
|
||||
fun SharedPreferences.putFloat(key: String, value: Float) { |
||||
edit { |
||||
putFloat(key, value) |
||||
} |
||||
} |
Loading…
Reference in new issue