RealmDictionary

interface RealmDictionary<V> : RealmMap<String, V>

A RealmDictionary is a specialization for RealmMaps whose keys are Strings.

Similarly to RealmList or RealmSet, RealmMap can operate in managed and unmanaged modes. In managed mode a RealmDictionary persists all its contents in a Realm instance whereas unmanaged dictionaries are backed by an in-memory LinkedHashMap.

A managed dictionary can only be created by Realm and will automatically update its content whenever its underlying realm is updated. Managed dictionaries can only be accessed using the getter that points to a RealmDictionary property of a managed RealmObject.

Unmanaged dictionaries can be created by calling realmDictionaryOf and may contain both managed and unmanaged RealmObjects. Unmanaged dictionaries can be added to a realm using the MutableRealm.copyToRealm function with an object containing an unmanaged dictionary.

A RealmDictionary may contain any type of Realm primitive nullable and non-nullable values. RealmObjects and EmbeddedRealmObjects are also supported but must be declared nullable.

Parameters

V

the type of the values stored in this map

Functions

asFlow
Link copied to clipboard
abstract fun asFlow(): Flow<MapChange<String, V>>
Observes changes to the RealmMap.
clear
Link copied to clipboard
abstract fun clear()
containsKey
Link copied to clipboard
abstract fun containsKey(key: String): Boolean
containsValue
Link copied to clipboard
abstract fun containsValue(value: V): Boolean
get
Link copied to clipboard
abstract operator fun get(key: String): V?
isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
put
Link copied to clipboard
abstract fun put(key: String, value: V): V?
putAll
Link copied to clipboard
abstract fun putAll(from: Map<out String, V>)
remove
Link copied to clipboard
abstract fun remove(key: String): V?

Properties

entries
Link copied to clipboard
abstract override val entries: MutableSet<MutableMap.MutableEntry<String, V>>
keys
Link copied to clipboard
abstract override val keys: MutableSet<String>
size
Link copied to clipboard
abstract val size: Int
values
Link copied to clipboard
abstract override val values: MutableCollection<V>

Extensions

copyFromRealm
Link copied to clipboard
inline fun <T : RealmObject> RealmDictionary<T?>.copyFromRealm(depth: UInt = UInt.MAX_VALUE): Map<String, T?>
Makes an unmanaged in-memory copy of the elements in a managed RealmDictionary.
query
Link copied to clipboard
fun <T : BaseRealmObject> RealmDictionary<T?>.query(filter: String = TRUE_PREDICATE, vararg arguments: Any?): RealmQuery<T>
Query the objects in a dictionary by filter and arguments.