Class RealmMap
On this page
io.realm
Implemented interfaces:
RealmMap is used to map keys to values. A RealmMap cannot contain duplicate keys and each key can map to at most one value. A RealmMap cannot have null
keys but can have null
values.
Similarly to RealmList s, a RealmDictionary can operate in managed and unmanaged modes. In managed mode a RealmDictionary persists all its contents inside a Realm whereas in unmanaged mode it functions like a HashMap .
Managed RealmDictionaries can only be created by Realm and will automatically update its content whenever the underlying Realm is updated. Managed RealmDictionaries can only be accessed using the getter that points to a RealmDictionary field of a RealmObject .
Unmanaged RealmDictionaries can be created by the user and can contain both managed and unmanaged RealmObjects. This is useful when dealing with JSON deserializers like GSON or other frameworks that inject values into a class. Unmanaged RealmMaps can be added to a Realm using the Realm.copyToRealm(Iterable, ImportFlag...) method.
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | Adds a change listener to this RealmMap . |
public void | Adds a change listener to this RealmMap . |
public void | clear () |
public boolean | |
public boolean | |
public Set | entrySet () |
public RealmMap | freeze () |
public V | |
public boolean | isEmpty () |
public boolean | isFrozen () |
public boolean | isManaged () |
public boolean | isValid () |
public Set | keySet () |
public V | |
public void | |
public V | |
public void | Removes all user-defined change listeners. |
public void | Removes the specified change listener. |
public void | Removes the specified change listener. |
public int | size () |
public Collection | values () |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
addChangeListener
Adds a change listener to this RealmMap . Registering a change listener will not prevent the underlying RealmMap from being garbage collected. If the RealmMap is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.
Parameters
Throws
|
Adds a change listener to this RealmMap . Registering a change listener will not prevent the underlying RealmMap from being garbage collected. If the RealmMap is garbage collected, the change listener will stop being triggered. To avoid this, keep a strong reference for as long as appropriate e.g. in a class variable.
Parameters
Throws
|
clear
public void clear () |
---|
containsKey
containsValue
entrySet
freeze
get
isEmpty
public boolean isEmpty () |
---|
isFrozen
public boolean isFrozen () |
---|
isManaged
public boolean isManaged () |
---|
isValid
public boolean isValid () |
---|
keySet
put
putAll
remove
removeAllChangeListeners
public void removeAllChangeListeners () |
---|
Removes all user-defined change listeners. Throws
|
removeChangeListener
Removes the specified change listener. Parameters
Throws
|
Removes the specified change listener. Parameters
Throws
|
size
public int size () |
---|
values
public Collection values () |
---|