public class Realm
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_REALM_NAME |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(RealmChangeListener listener)
Add a change listener to the Realm
|
<E extends RealmObject> |
allObjects(java.lang.Class<E> clazz)
Get all objects of a specific Class
|
void |
beginTransaction()
Starts a write transaction, this must be closed with commitTransaction()
|
void |
clear(java.lang.Class<?> classSpec)
Remove all objects of the specified class
|
void |
commitTransaction()
Commits a write transaction
|
static Realm |
create(java.io.File writableFolder,
java.lang.String filename,
byte[] key)
Realm static constructor
|
<E extends RealmObject> |
createObject(java.lang.Class<E> clazz)
Instantiates and adds a new object to the realm
|
static boolean |
deleteRealmFile(android.content.Context context)
Delete the Realm file from the filesystem for the default Realm (named "default.realm").
|
static boolean |
deleteRealmFile(android.content.Context context,
java.lang.String fileName)
Delete the Realm file from the filesystem for a custom named Realm.
|
protected void |
finalize() |
static Realm |
getInstance(android.content.Context context)
Realm static constructor for the default realm "default.realm"
|
static Realm |
getInstance(android.content.Context context,
byte[] key)
Realm static constructor
|
static Realm |
getInstance(android.content.Context context,
java.lang.String fileName)
Realm static constructor
|
static Realm |
getInstance(android.content.Context context,
java.lang.String fileName,
byte[] key)
Realm static constructor
|
static Realm |
getInstance(java.io.File writableFolder,
byte[] key)
Realm static constructor
|
Table |
getTable(java.lang.Class<?> clazz) |
static void |
migrateRealmAtPath(java.lang.String realmPath,
byte[] key,
RealmMigration migration) |
static void |
migrateRealmAtPath(java.lang.String realmPath,
RealmMigration migration) |
void |
removeAllChangeListeners()
Remove all user-defined change listeners
|
void |
removeChangeListener(RealmChangeListener listener)
Remove the specified change listener
|
<E extends RealmObject> |
where(java.lang.Class<E> clazz)
Returns a typed RealmQuery, which can be used to query for specific objects of this type
|
public static final java.lang.String DEFAULT_REALM_NAME
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public Table getTable(java.lang.Class<?> clazz)
public static Realm getInstance(android.content.Context context)
context
- an Android contextpublic static Realm getInstance(android.content.Context context, java.lang.String fileName)
context
- an Android contextfileName
- the name of the file to save the Realm topublic static Realm getInstance(android.content.Context context, byte[] key)
context
- an Android contextkey
- a 32-byte encryption keypublic static Realm getInstance(android.content.Context context, java.lang.String fileName, byte[] key)
context
- an Android contextfileName
- the name of the file to save the Realm tokey
- a 32-byte encryption keypublic static Realm getInstance(java.io.File writableFolder, byte[] key)
writableFolder
- absolute path to a writable directorykey
- a 32-byte encryption keypublic static Realm create(java.io.File writableFolder, java.lang.String filename, byte[] key)
writableFolder
- absolute path to a writable directoryfilename
- the name of the file to save the Realm tokey
- a 32-byte encryption keypublic <E extends RealmObject> E createObject(java.lang.Class<E> clazz)
clazz
- The Class of the object to createpublic <E extends RealmObject> RealmQuery<E> where(java.lang.Class<E> clazz)
clazz
- The class of the object which is to be queried forRealmQuery
public <E extends RealmObject> RealmResults<E> allObjects(java.lang.Class<E> clazz)
clazz
- the Class to get objects ofRealmResults
public void addChangeListener(RealmChangeListener listener)
listener
- the change listenerRealmChangeListener
public void removeChangeListener(RealmChangeListener listener)
listener
- the change listener to be removedRealmChangeListener
public void removeAllChangeListeners()
RealmChangeListener
public void beginTransaction()
public void commitTransaction()
public void clear(java.lang.Class<?> classSpec)
classSpec
- The class which objects should be removedpublic static void migrateRealmAtPath(java.lang.String realmPath, RealmMigration migration)
public static void migrateRealmAtPath(java.lang.String realmPath, byte[] key, RealmMigration migration)
public static boolean deleteRealmFile(android.content.Context context)
context
- an Android context.clear(Class)
public static boolean deleteRealmFile(android.content.Context context, java.lang.String fileName)
context
- an Android context.fileName
- the name of the custom Realm (i.e. "myCustomRealm.realm").