MMKV

interface MMKV

MMKV multiplatform interface

Facade for all platforms; implemented by each specific target.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun allKeys(): List<String>

Get all keys

Link copied to clipboard
abstract fun clear()

Note: this does NOT delete files on disk.

Link copied to clipboard
abstract fun destroy(): Boolean

Note: this destroys the in-memory instance AND deletes files on disk.

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

Check whether the specified key exists

Link copied to clipboard
inline fun <T : Parcelable> MMKV.get(key: String): T?

Get a Parcelable value

fun <T : Parcelable> MMKV.get(key: String, clazz: KClass<T>): T?
Link copied to clipboard
abstract fun getBoolean(key: String): Boolean

Get a boolean value

Link copied to clipboard
abstract fun getByteArray(key: String): ByteArray

Get a byte array value

Link copied to clipboard
abstract fun getDouble(key: String): Double

Get a double value

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

Get a float value

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

Get an integer value

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

Get a long value

Link copied to clipboard
abstract fun getString(key: String): String

Get a string value

Link copied to clipboard
abstract fun getStringList(key: String): List<String>

Get a list of strings

Link copied to clipboard

Import data from SharedPreferences

Link copied to clipboard
abstract fun isAlive(): Boolean
Link copied to clipboard
abstract fun remove(key: String): Boolean

Remove the value for the specified key

Link copied to clipboard
abstract fun set(key: String, value: Boolean, expire: Int = 0)

Set a boolean value

abstract fun set(key: String, value: ByteArray, expire: Int = 0)

Set a byte array value

abstract fun set(key: String, value: Double, expire: Int = 0)

Set a double value

abstract fun set(key: String, value: Float, expire: Int = 0)

Set a float value

abstract fun set(key: String, value: Int, expire: Int = 0)

Set an integer value

abstract fun set(key: String, value: Long, expire: Int = 0)

Set a long value

abstract fun set(key: String, value: String, expire: Int = 0)

Set a string value

abstract fun set(key: String, value: List<String>, expire: Int = 0)

Set a list of strings

Link copied to clipboard
fun <T : Parcelable> MMKV.set(key: String, value: T, expire: Int = 0)

Set a Parcelable value

Link copied to clipboard
abstract fun size(): Int

Get the number of stored key-value pairs