SharedPreferenceManager

class SharedPreferenceManager(context: Context, preferenceName: String, encrypted: Boolean = false, val gson: Gson = Gson())

SharedPreferenceManager is android.content.SharedPreferences class within Arc

Author

jimlyas

Since

06 Nov 2023

Parameters

context

Context used to create the instance of android.content.SharedPreferences

preferenceName
encrypted

Boolean to define does the android.content.SharedPreferences is encrypted or not, if true, will use EncryptedSharedPreferences. And if not, will use default android.content.SharedPreferences from Context

gson

Gson instance that used for parsing object to String

Constructors

Link copied to clipboard
constructor(context: Context, preferenceName: String, encrypted: Boolean = false, gson: Gson = Gson())

Functions

Link copied to clipboard
fun clear()

Function to clear all values from the preference

Link copied to clipboard
inline fun <model> get(key: String): model?

Function to get model value from preference

Link copied to clipboard
fun getBoolean(key: String, defaultValue: Boolean = false): Boolean

Function to get Boolean value from preference

Link copied to clipboard
fun getFloat(key: String, defaultValue: Float = MIN_VALUE): Float

Function to get Float value from preference

Link copied to clipboard
fun getInt(key: String, defaultValue: Int = 0): Int

Function to get Int value from preference

Link copied to clipboard
fun getLong(key: String, defaultValue: Long = 0): Long

Function to get Long value from preference

Link copied to clipboard
fun getString(key: String, defaultValue: String = ""): String?

Function to get String value from preference

Link copied to clipboard
fun remove(key: String)

Function to remove value from preference based on given key

Link copied to clipboard
fun <model> set(key: String, value: model)

Function to set a Object value to preference

Link copied to clipboard
fun setBoolean(key: String, value: Boolean)

Function to set a Boolean value to preference

Link copied to clipboard
fun setFloat(key: String, value: Float)

Function to set a Float value to preference

Link copied to clipboard
fun setInt(key: String, value: Int)

Function to set a Int value to preference

Link copied to clipboard
fun setLong(key: String, value: Long)

Function to set a Long value to preference

Link copied to clipboard
fun setString(key: String, value: String)

Function to set a String value to preference

Properties

Link copied to clipboard
val gson: Gson