public abstract class RealmObject
extends java.lang.Object
An annotation processor will create a proxy class for your RealmObject subclass. The getters and setters should not contain any custom code of logic as they are overridden as part of the annotation process.
A RealmObject is currently limited to the following:
The following field data types are supported (no boxed types):
The types short
, int
, and long
are mapped to long
when storing within a Realm.
Getter and setter names must have the name getXXX
or setXXX
if
the field name is XXX
. Getters for fields of type boolean can be called isXXX
as
well. Fields with a m-prefix must have getters and setters named setmXXX and getmXXX which is
the default behavior when Android Studio automatically generates the getters and setters.
Fields annotated with Ignore
don't have these restrictions and
don't require either a getter or setter.
Realm will create indexes for fields annotated with Index
. This
will speedup queries but will have a negative impact on inserts and updates.
*
A RealmObject cannot be passed between different threads.
Modifier and Type | Field and Description |
---|---|
protected Realm |
realm |
protected Row |
row |
Constructor and Description |
---|
RealmObject() |
Modifier and Type | Method and Description |
---|---|
boolean |
isValid()
Check if the RealmObject is still valid to use ie.
|
void |
removeFromRealm()
Removes the object from the Realm it is currently associated to.
|
protected Row row
protected Realm realm
public void removeFromRealm()
After this method is called the object will be invalid and any operation (read or write) performed on it will fail with an IllegalStateException
public boolean isValid()
Realm
been closed. It will always return false for stand alone
objects.true
if the object is still accessible, false
otherwise or if it is a
standalone object.