SharedPreferencesHelper

@Singleton
class SharedPreferencesHelper @Inject constructor(val context: Context, val gson: Gson)

Constructors

Link copied to clipboard
@Inject
constructor(context: Context, gson: Gson)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
val gson: Gson
Link copied to clipboard

Functions

Link copied to clipboard
fun read(key: String, defaultValue: Boolean): Boolean
fun read(key: String, defaultValue: Long): Long
fun read(key: String, defaultValue: String?): String?

inline fun <T> read(key: String, decodeWithGson: Boolean = true): T?

Read any JSON object with type T

Link copied to clipboard
fun remove(key: String)
Link copied to clipboard

This method resets/clears all existing values in the shared preferences asynchronously

Link copied to clipboard
Link copied to clipboard
fun write(key: String, value: Boolean)
fun write(key: String, value: Long)
fun write(key: String, value: String?)

inline fun <T> write(key: String, value: T?, encodeWithGson: Boolean = true)

Write any object by saving it as JSON