public class RealmConfiguration extends Object
Instances of a RealmConfiguration can only created by using the RealmConfiguration.Builder
and calling
its RealmConfiguration.Builder.build()
method.
A commonly used RealmConfiguration can easily be accessed by first saving it as
Realm.setDefaultConfiguration(RealmConfiguration)
and then using Realm.getDefaultInstance()
.
A minimal configuration can be created using:
RealmConfiguration config = new RealmConfiguration.Builder().build()
This will create a RealmConfiguration with the following properties.
Modifier and Type | Class and Description |
---|---|
static class |
RealmConfiguration.Builder
RealmConfiguration.Builder used to construct instances of a RealmConfiguration in a fluent manner.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_REALM_NAME |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
CompactOnLaunchCallback |
getCompactOnLaunchCallback()
Returns a callback to determine if the Realm file should be compacted before being returned to the user.
|
OsRealmConfig.Durability |
getDurability() |
byte[] |
getEncryptionKey() |
long |
getMaxNumberOfActiveVersions() |
RealmMigration |
getMigration() |
String |
getPath()
Returns the absolute path to where the Realm file will be saved.
|
File |
getRealmDirectory() |
String |
getRealmFileName() |
Set<Class<? extends RealmModel>> |
getRealmObjectClasses()
Returns the unmodifiable
Set of model classes that make up the schema for this Realm. |
RxObservableFactory |
getRxFactory()
Returns the
RxObservableFactory that is used to create Rx Observables from Realm objects. |
long |
getSchemaVersion() |
int |
hashCode() |
boolean |
isAllowQueriesOnUiThread()
Returns whether a
RealmQuery is allowed to be launched from the UI thread. |
boolean |
isAllowWritesOnUiThread()
Returns whether calls to
Realm.executeTransaction(io.realm.Realm.Transaction) can be done on the UI thread. |
boolean |
isReadOnly()
Returns whether this Realm is read-only or not.
|
boolean |
isRecoveryConfiguration() |
boolean |
shouldDeleteRealmIfMigrationNeeded() |
String |
toString() |
public static final String DEFAULT_REALM_NAME
public File getRealmDirectory()
public String getRealmFileName()
public byte[] getEncryptionKey()
public long getSchemaVersion()
public RealmMigration getMigration()
public boolean shouldDeleteRealmIfMigrationNeeded()
public OsRealmConfig.Durability getDurability()
public CompactOnLaunchCallback getCompactOnLaunchCallback()
public Set<Class<? extends RealmModel>> getRealmObjectClasses()
Set
of model classes that make up the schema for this Realm.Set
of model classes.public String getPath()
public RxObservableFactory getRxFactory()
RxObservableFactory
that is used to create Rx Observables from Realm objects.UnsupportedOperationException
- if the required RxJava framework is not on the classpath.public boolean isReadOnly()
IllegalStateException
if BaseRealm.beginTransaction()
is called on it.true
if this Realm is read only, false
if not.public boolean isRecoveryConfiguration()
true
if this configuration is intended to open a backup Realm (as a result of a client reset).public long getMaxNumberOfActiveVersions()
public boolean isAllowWritesOnUiThread()
Realm.executeTransaction(io.realm.Realm.Transaction)
can be done on the UI thread.
Note: Realm does not allow blocking transactions to be run on the main thread unless users explicitly opt in with
RealmConfiguration.Builder.allowWritesOnUiThread(boolean)
or its Realm Sync builder counterpart.
public boolean isAllowQueriesOnUiThread()
RealmQuery
is allowed to be launched from the UI thread.
By default Realm allows queries on the main thread. To disallow this users have to explicitly opt in with
RealmConfiguration.Builder.allowQueriesOnUiThread(boolean)
or its Realm Sync builder counterpart.