JsonSettings

class JsonSettings(fileDirectory: String, fileName: String)

Utility class that acts as settings storage. Uses JSON.

See also

SettingsUtilsJSON

(https://github.com/Aliucord/Aliucord/blob/main/Aliucord/src/main/java/com/aliucord/SettingsUtilsJSON.kt)

Constructors

Link copied to clipboard
constructor(fileDirectory: String, fileName: String)

Properties

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

Functions

Link copied to clipboard
fun exists(key: String): Boolean

Check if Key exists in settings

Link copied to clipboard

Gets All Keys from settings

Link copied to clipboard
fun getBool(key: String, defaultValue: Boolean): Boolean

Get a boolean from the preferences

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

Get a float from the preferences

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

Get an int from the preferences

Link copied to clipboard
fun getJSONObject(key: String, defaultValue: JSONObject?): JSONObject?

Get a JSONObject item

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

Get a long from the preferences

Link copied to clipboard
inline fun <T> getObject(key: String, defaultValue: T? = null): T?

Get an Object from the preferences

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

Get a String from the preferences

Link copied to clipboard

Removes Item from settings

Link copied to clipboard

Resets all settings

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

Set a boolean item

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

Set a float item

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

Set an int item

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

Set a JSONObject item

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

Set a long item

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

Set an Object item

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

Set a String item

Link copied to clipboard
fun toggleBool(key: String, defVal: Boolean): Boolean

Toggles Boolean and returns it