Docs Menu

Docs HomeDevelop ApplicationsAtlas Device SDKs

Class RealmConfiguration

On this page

  • io.realm
  • Nested Class Summary
  • Field Summary
  • Method Summary
  • Inherited Methods
  • Field Detail
  • DEFAULT_REALM_NAME
  • Method Detail
  • createSchemaMediator
  • equals
  • forRecovery
  • getAssetFilePath
  • getCompactOnLaunchCallback
  • getDurability
  • getEncryptionKey
  • getFlowFactory
  • getInitialDataTransaction
  • getInstance
  • getMaxNumberOfActiveVersions
  • getMigration
  • getPath
  • getRealmDirectory
  • getRealmFileName
  • getRealmObjectClasses
  • getRxFactory
  • getSchemaMediator
  • getSchemaVersion
  • hasAssetFile
  • hashCode
  • isAllowQueriesOnUiThread
  • isAllowWritesOnUiThread
  • isReadOnly
  • isRecoveryConfiguration
  • isSyncConfiguration
  • realmExists
  • shouldDeleteRealmIfMigrationNeeded
  • toString
io.realm.RealmConfiguration

A RealmConfiguration is used to setup a specific Realm instance.Instances of a RealmConfiguration can only created by using the io.realm.RealmConfiguration.Builder and calling its io.realm.RealmConfiguration.Builder.build() method.

A commonly used RealmConfiguration can easily be accessed by first saving it as Realm.setDefaultConfiguration(RealmConfiguration) and then using io.realm.Realm.getDefaultInstance() .

A minimal configuration can be created using:

RealmConfiguration config = new RealmConfiguration.Builder().build()

This will create a RealmConfiguration with the following properties.

  • Realm file is called "default.realm"

  • It is saved in Context.getFilesDir()

  • It has its schema version set to 0.

Modifier and Type
Class and Description
public static
Modifier and Type
Field and Description
public static final String
Modifier and Type
Method and Description
protected static RealmProxyMediator
public boolean
protected static RealmConfiguration
String canonicalPath,
byte[] encryptionKey,
RealmProxyMediator schemaMediator
)
public String

Returns the path to the Realm asset file.

Returns a callback to determine if the Realm file should be compacted before being returned to the user.

public OsRealmConfig.Durability
public byte

Returns the FlowFactory that is used to create Kotlin Flows from Realm objects.

Returns the transaction instance with initial data.

protected Realm
OsSharedRealm.VersionID version
)
public long
public String

Returns the absolute path to where the Realm file will be saved.

public File
public String
public Set

Returns the unmodifiable Set of model classes that make up the schema for this Realm.

Returns the RxObservableFactory that is used to create Rx Observables from Realm objects.

protected RealmProxyMediator

Returns the mediator instance of schema which is defined by this configuration.

public long
public boolean

Indicates if an asset file has been configured for this configuration.

public int
public boolean

Returns whether a RealmQuery is allowed to be launched from the UI thread.

public boolean

Returns whether calls to Realm.executeTransaction can be done on the UI thread.

public boolean

Returns whether this Realm is read-only or not.

public boolean
protected boolean
protected boolean

Checks if the Realm file defined by this configuration already exists.

public boolean
public String
  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

protected static RealmProxyMediator createSchemaMediator (
)
public boolean equals (
Object obj
)

Overrides

equals in class Object

protected static RealmConfiguration forRecovery (
String canonicalPath,
byte[] encryptionKey,
RealmProxyMediator schemaMediator
)

Returns the path to the Realm asset file.

Returns

path to the asset file relative to the asset directory or null if not asset file was specified.

Returns a callback to determine if the Realm file should be compacted before being returned to the user.

Returns

a callback called when opening a Realm for the first time during the life of a process to determine if it should be compacted before being returned to the user. It is passed the total file size (data + free space) and the total bytes used by data in the file.

public OsRealmConfig.Durability getDurability ()

public byte getEncryptionKey ()

Returns the FlowFactory that is used to create Kotlin Flows from Realm objects.

Returns

the factory instance used to create Flows.

Throws

Returns the transaction instance with initial data.

Returns

the initial data transaction.

protected Realm getInstance (
OsSharedRealm.VersionID version
)

Returns

the maximum number of active versions allowed before an exception is thrown.

public String getPath ()

Returns the absolute path to where the Realm file will be saved.

Returns

the absolute path to the Realm file defined by this configuration.

Returns the unmodifiable Set of model classes that make up the schema for this Realm.

Returns

unmodifiable Set of model classes.

Returns the RxObservableFactory that is used to create Rx Observables from Realm objects.

Returns

the factory instance used to create Rx Observables.

Throws

protected RealmProxyMediator getSchemaMediator ()

Returns the mediator instance of schema which is defined by this configuration.

Returns

the mediator of the schema.

public long getSchemaVersion ()

public boolean hasAssetFile ()

Indicates if an asset file has been configured for this configuration.

Returns

true if there is asset file, false otherwise.

public int hashCode ()

Overrides

hashCode in class Object

public boolean isAllowQueriesOnUiThread ()

Returns whether a 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 Builder.allowQueriesOnUiThread(boolean) or its Realm Sync builder counterpart.

Returns

whether or not queries are allowed to be run from the UI thread.

public boolean isAllowWritesOnUiThread ()

Returns whether calls to Realm.executeTransaction 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 Builder.allowWritesOnUiThread(boolean) or its Realm Sync builder counterpart.

Returns

whether or not write operations are allowed to be run from the UI thread.

public boolean isReadOnly ()

Returns whether this Realm is read-only or not. Read-only Realms cannot be modified and will throw an IllegalStateException if Realm.beginTransaction() is called on it.

Returns

true if this Realm is read only, false if not.

public boolean isRecoveryConfiguration ()

Returns

true if this configuration is intended to open a backup Realm (as a result of a client reset).

Tip

See also:

  • {@link ClientResetRequiredError}

protected boolean isSyncConfiguration ()

protected boolean realmExists ()

Checks if the Realm file defined by this configuration already exists.WARNING: This method is just a point-in-time check. Unless protected by external synchronization another thread or process might have created or deleted the Realm file right after this method has returned.

Returns

true if the Realm file exists, false otherwise.

public String toString ()

Overrides

toString in class Object

← Interface RealmCollection