Class RealmResults
On this page
- io.realm
- Method Summary
- Inherited Methods
- Method Detail
- addChangeListener
- asChangesetObservable
- asFlowable
- asJSON
- freeze
- isFrozen
- isLoaded
- load
- removeAllChangeListeners
- removeChangeListener
- setBlob
- setBoolean
- setByte
- setDate
- setDecimal128
- setDouble
- setFloat
- setInt
- setList
- setLong
- setNull
- setObject
- setObjectId
- setShort
- setString
- setUUID
- setValue
- sort
- where
io.realm
This class holds all the matches of a RealmQuery for a given Realm. The objects are not copied from the Realm to the RealmResults list, but are just referenced from the RealmResult instead. This saves memory and increases speed.
RealmResults are live views, which means that if it is on an Looper thread, it will automatically update its query results after a transaction has been committed. If on a non-looper thread, Realm.refresh() must be called to update the results.
Updates to RealmObjects from a RealmResults list must be done from within a transaction and the modified objects are persisted to the Realm file during the commit of the transaction.
A RealmResults object cannot be passed between different threads.
Notice that a RealmResults is never null
not even in the case where it contains no objects. You should always use the RealmResults.size() method to check if a RealmResults is empty or not.
If a RealmResults is built on RealmList through RealmList.where() , it will become empty when the source RealmList gets deleted.
RealmResults can contain more elements than Integer.MAX_VALUE
. In that case, you can access only first Integer.MAX_VALUE
elements in it.
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | ) Adds a change listener to this RealmResults . |
public void | Adds a change listener to this RealmResults . |
public <any> | Returns an Rx Observable that monitors changes to this RealmResults. |
public <any> | asFlowable () Returns an Rx Flowable that monitors changes to this RealmResults. |
public String | asJSON () Returns a JSON representation of the matches of a RealmQuery . |
public RealmResults | freeze () |
public boolean | isFrozen () |
public boolean | isLoaded () Returns |
public boolean | load () Makes an asynchronous query blocking. |
public void | Removes all user-defined change listeners. |
public void | ) Removes the specified change listener. |
public void | Removes the specified change listener. |
public void | |
public void | Sets the |
public void | |
public void | |
public void | Sets the |
public void | |
public void | |
public void | |
public void | Replaces the RealmList at the given field on all objects in this collection. |
public void | |
public void | |
public void | Sets a reference to another object on the given field in all of the objects in the collection. |
public void | Sets the |
public void | |
public void | |
public void | |
public void | |
public RealmResults | |
public RealmQuery | where () Returns a RealmQuery , which can be used to query for specific objects from this collection. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Methods inherited from class java.util.AbstractCollection :
iterator
,size
,isEmpty
,contains
,toArray
,toArray
,add
,remove
,containsAll
,addAll
,removeAll
,retainAll
,clear
,toString
Methods inherited from class java.util.AbstractList :
add
,get
,set
,add
,remove
,indexOf
,lastIndexOf
,clear
,addAll
,iterator
,listIterator
,listIterator
,subList
,equals
,hashCode
,removeRange
Methods inherited from class io.realm.OrderedRealmCollectionImpl:
isValid
,isManaged
,contains
,get
,first
,first
,last
,last
,deleteFromRealm
,deleteAllFromRealm
,iterator
,listIterator
,listIterator
,sort
,sort
,sort
,sort
,size
,min
,minDate
,max
,maxDate
,sum
,average
,remove
,remove
,removeAll
,set
,retainAll
,deleteLastFromRealm
,deleteFirstFromRealm
,clear
,add
,add
,addAll
,addAll
,createSnapshot
,getRealm
,getCollectionOperator
Method Detail
addChangeListener
public void addChangeListener ( ) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Adds a change listener to this RealmResults . Registering a change listener will not prevent the underlying RealmResults from being garbage collected. If the RealmResults 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 RealmResults . Registering a change listener will not prevent the underlying RealmResults from being garbage collected. If the RealmResults 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
|
asChangesetObservable
public <any> asChangesetObservable () | |||||
---|---|---|---|---|---|
Returns an Rx Observable that monitors changes to this RealmResults. It will emit the current RealmResults when subscribed. For each update to the RealmResult a pair consisting of the RealmResults and the OrderedCollectionChangeSet will be sent. The changeset will be RealmResults will continually be emitted as the RealmResults are updated - Items emitted from Realm Observables are frozen (See freeze() . This means that they are immutable and can be read on any thread. Realm Observables always emit items from the thread holding the live Realm. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler:
Returns RxJava Observable that only calls Throws
|
asFlowable
public <any> asFlowable () | |||||||||
---|---|---|---|---|---|---|---|---|---|
Returns an Rx Flowable that monitors changes to this RealmResults. It will emit the current RealmResults when subscribed to. RealmResults will continually be emitted as the RealmResults are updated - Items emitted from Realm Flowables are frozen (See freeze() . This means that they are immutable and can be read on any thread. Realm Flowables always emit items from the thread holding the live RealmResults. This means that if you need to do further processing, it is recommend to observe the values on a computation scheduler:
If you would like the
Returns RxJava Observable that only calls Throws
|
asJSON
Returns a JSON representation of the matches of a RealmQuery . Cycles will be returned as row indices. This is a helper method used to inspect data, or for debugging purpose, this method could pull a large string which could cause an OutOfMemory error. Returns string representation of a JSON array containing entries of the resulting RealmQuery . |
freeze
public RealmResults freeze () |
---|
isFrozen
public boolean isFrozen () |
---|
isLoaded
public boolean isLoaded () |
---|
Returns Returns
|
load
public boolean load () |
---|
Makes an asynchronous query blocking. This will also trigger any registered RealmChangeListener when the query completes. Returns
|
removeAllChangeListeners
public void removeAllChangeListeners () |
---|
Removes all user-defined change listeners. Throws
|
removeChangeListener
public void removeChangeListener ( ) |
---|
Removes the specified change listener. Parameters
Throws
|
Removes the specified change listener. Parameters
Throws
|
setBlob
Sets the binary value of the given field in all of the objects in the collection. Parameters
Throws
|
setBoolean
Sets the Parameters
Throws
|
setByte
Sets the Parameters
Throws
|
setDate
Sets the Parameters
Throws
|
setDecimal128
Sets the Parameters
Throws
|
setDouble
Sets the Parameters
Throws
|
setFloat
Sets the Parameters
Throws
|
setInt
Sets the Parameters
Throws
|
setList
Replaces the RealmList at the given field on all objects in this collection. Parameters
Throws
|
setLong
Sets the Parameters
Throws
|
setNull
Sets the value to Parameters
Throws
|
setObject
Sets a reference to another object on the given field in all of the objects in the collection. Parameters
Throws
|
setObjectId
Sets the Parameters
Throws
|
setShort
Sets the Parameters
Throws
|
setString
Sets the Parameters
Throws
|
setUUID
Sets the Parameters
Throws
|
setValue
Updates the field given by This method will automatically try to convert numbers and booleans that are given as Using the typed setters like setInt(String, int) will be faster than using this method. Parameters
Throws
|
sort
Sorts a collection based on the provided fields and sort orders. Returns a new sorted RealmResults will be created and returned. The original collection stays unchanged. Overrides
|
where
public RealmQuery where () |
---|
Returns a RealmQuery , which can be used to query for specific objects from this collection. Returns a RealmQuery object. |