public abstract class BaseRealm
extends java.lang.Object
implements java.io.Closeable
Realm, 
DynamicRealm| Modifier and Type | Method and Description | 
|---|---|
void | 
addChangeListener(RealmChangeListener listener)
Adds a change listener to the Realm. 
 | 
abstract Observable | 
asObservable()
Returns an RxJava Observable that monitors changes to this Realm. 
 | 
void | 
beginTransaction()
Starts a transaction, this must be closed with  
commitTransaction() or aborted by
 cancelTransaction(). | 
void | 
cancelTransaction()
Reverts all writes (created, updated, or deleted objects) made in the current write transaction and end the
 transaction. 
 | 
void | 
close()
Closes the Realm instance and all its resources. 
 | 
void | 
commitTransaction()
All changes since  
beginTransaction() are persisted to disk and the Realm reverts back to
 being read-only. | 
void | 
deleteAll()
Deletes all objects from this Realm. 
 | 
RealmConfiguration | 
getConfiguration()
Returns the  
RealmConfiguration for this Realm. | 
java.lang.String | 
getPath()
Returns the canonical path to where this Realm is persisted on disk. 
 | 
RealmSchema | 
getSchema()
Returns the schema for this Realm. 
 | 
long | 
getVersion()
Returns the schema version for this Realm. 
 | 
boolean | 
isAutoRefresh()
Retrieves the auto-refresh status of the Realm instance. 
 | 
boolean | 
isClosed()
Checks if the  
Realm instance has already been closed. | 
boolean | 
isEmpty()
Checks if this  
Realm contains any objects. | 
boolean | 
isInTransaction()
Checks if the Realm is currently in a transaction. 
 | 
void | 
refresh()
Refreshes the Realm instance and all the RealmResults and RealmObjects instances coming from it. 
 | 
void | 
removeAllChangeListeners()
Removes all user-defined change listeners. 
 | 
void | 
removeChangeListener(RealmChangeListener listener)
Removes the specified change listener. 
 | 
void | 
setAutoRefresh(boolean autoRefresh)
Sets the auto-refresh status of the Realm instance. 
 | 
void | 
writeCopyTo(java.io.File destination)
Writes a compacted copy of the Realm to the given destination File. 
 | 
void | 
writeEncryptedCopyTo(java.io.File destination,
                    byte[] key)
Writes a compacted and encrypted copy of the Realm to the given destination File. 
 | 
public void setAutoRefresh(boolean autoRefresh)
 Auto-refresh is a feature that enables automatic update of the current Realm instance and all its derived objects
 (RealmResults and RealmObjects instances) when a commit is performed on a Realm acting on the same file in
 another thread. This feature is only available if the Realm instance lives is a Looper enabled
 thread.
autoRefresh - true will turn auto-refresh on, false will turn it off.java.lang.IllegalStateException - if called from a non-Looper thread.public boolean isAutoRefresh()
public boolean isInTransaction()
true if inside a transaction, false otherwise.public void addChangeListener(RealmChangeListener listener)
The listeners will be executed:
refresh()removeChangeListener(RealmChangeListener)
 or removeAllChangeListeners() which removes all listeners including the ones added via anonymous classes.listener - the change listener.java.lang.IllegalStateException - if you try to register a listener from a non-Looper Thread.RealmChangeListener, 
removeChangeListener(RealmChangeListener), 
removeAllChangeListeners()public void removeChangeListener(RealmChangeListener listener)
listener - the change listener to be removed.java.lang.IllegalStateException - if you try to remove a listener from a non-Looper Thread.RealmChangeListener, 
addChangeListener(RealmChangeListener)public abstract Observable asObservable()
onComplete will never be called.
 If you would like the asObservable() to stop emitting items you can instruct RxJava to
 only emit only the first item by using the first() operator:
 
 
 realm.asObservable().first().subscribe( ... ) // You only get the results once
 
 onNext. It will never call onComplete or OnError.java.lang.UnsupportedOperationException - if the required RxJava framework is not on the classpath.public void removeAllChangeListeners()
java.lang.IllegalStateException - if you try to remove listeners from a non-Looper Thread.RealmChangeListener, 
addChangeListener(RealmChangeListener)public void writeCopyTo(java.io.File destination)
                 throws java.io.IOException
The destination file cannot already exist.
Note that if this is called from within a transaction it writes the current data, and not the data as it was when the last transaction was committed.
destination - file to save the Realm to.java.io.IOException - if any write operation fails.public void writeEncryptedCopyTo(java.io.File destination,
                                 byte[] key)
                          throws java.io.IOException
The destination file cannot already exist.
Note that if this is called from within a transaction it writes the current data, and not the data as it was when the last transaction was committed.
destination - file to save the Realm to.key - a 64-byte encryption key.java.io.IOException - if any write operation fails.java.lang.IllegalArgumentException - if destination argument is null.public void refresh()
java.lang.IllegalStateException - if attempting to refresh from within a transaction.public void beginTransaction()
commitTransaction() or aborted by
 cancelTransaction(). Transactions are used to atomically create, update and delete objects
 within a Realm.
 beginTransaction() updates the realm in the case of
 pending updates from other threads.
 public void commitTransaction()
beginTransaction() are persisted to disk and the Realm reverts back to
 being read-only. An event is sent to notify all other Realm instances that a change has occurred. When the event
 is received, the other Realms will get their objects and RealmResults updated to reflect the
 changes from this commit.public void cancelTransaction()
public java.lang.String getPath()
File.getCanonicalPath()public RealmConfiguration getConfiguration()
RealmConfiguration for this Realm.RealmConfiguration for this Realm.public long getVersion()
public void close()
It's important to always remember to close Realm instances when you're done with it in order not to leak memory, file descriptors or grow the size of Realm file out of measure.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.lang.IllegalStateException - if attempting to close from another thread.public boolean isClosed()
Realm instance has already been closed.true if closed, false otherwise.java.lang.IllegalStateException - if attempting to close from another thread.public boolean isEmpty()
Realm contains any objects.true if empty, @{code false} otherwise.public RealmSchema getSchema()
RealmSchema for this Realm.public void deleteAll()
java.lang.IllegalStateException - if the corresponding Realm is closed or called from an incorrect thread.