RealmDictionary (beta) - Android SDK¶
New in version 10.6.0.
This feature is currently in beta. While we encourage you to try out the feature and give feedback, please be aware the API may change.
You can use the RealmDictionary data type to manage a collection of
String keys paired with values.
Map interface, so it works just like the built-in
HashMap class, except managed
RealmDictionary instances persist
their contents to a realm.
RealmDictionary instances that
contain Realm objects store references to those objects.
When you delete a Realm object from a realm, any
references to that object in a
To create a field of type
RealmDictionary, define an object property
T defines the values you would
like to store in your
instances can only use keys of type
- Add an object to a
RealmDictionarywith RealmDictionary.put() (or the
operator in Kotlin)
- Add multiple objects to a
- Check if the dictionary contains an specific key with RealmDictionary.containsKey()
- Check if the dictionary contains a specific value with RealmDictionary.containsValue()
To subscribe to changes to a
RealmDictionary, pass a
implementation to the RealmSet.addChangeListener method.
MapChangeListener implementation must define an
onChange() method, which accepts a reference to the changed
and a set of changes as parameters. You can access the keys
added to the dictionary as well as the keys removed from the dictionary