Builder

Used to create a RealmConfiguration. For common use cases, a RealmConfiguration can be created using the RealmConfiguration.create function.

Constructors

Link copied to clipboard
constructor(schema: Set<KClass<out TypedRealmObject>>)

Functions

Link copied to clipboard
open override fun build(): RealmConfiguration

Creates the RealmConfiguration based on the builder properties.

Link copied to clipboard
fun compactOnLaunch(callback: CompactOnLaunchCallback = Realm.DEFAULT_COMPACT_ON_LAUNCH_CALLBACK): RealmConfiguration.Builder

Sets a callback for controlling whether the realm should be compacted when opened.

Link copied to clipboard

Setting this will change the behavior of how migration exceptions are handled. Instead of throwing an exception the on-disc Realm will be cleared and recreated with the new Realm schema.

Link copied to clipboard

Sets the path to the directory that contains the realm file. If the directory does not exists, it and all intermediate directories will be created.

Link copied to clipboard

Sets the 64 byte key used to encrypt and decrypt the Realm file. If no key is provided the Realm file will be unencrypted.

Link copied to clipboard

Writes initial data to the Realm file. This callback will be executed only once, when the database file is created. This also include cases where RealmConfiguration.Builder.deleteRealmIfMigrationNeeded was set causing the file to be deleted.

Link copied to clipboard
fun initialRealmFile(assetFile: String, sha256checkSum: String? = null): RealmConfiguration.Builder

Initializes a realm file with a bundled asset realm file.

Link copied to clipboard

Setting this will create an in-memory Realm instead of saving it to disk. In-memory Realms might still use disk space if memory is running low, but all files created by an in-memory Realm will be deleted when the Realm is closed.

Link copied to clipboard
open fun log(level: LogLevel = LogLevel.WARN, customLoggers: List<RealmLogger> = emptyList()): RealmConfiguration.Builder

Configure how Realm will report log events.

Link copied to clipboard

Sets the maximum number of live versions in the Realm file before an IllegalStateException is thrown when attempting to write more data.

Link copied to clipboard

Sets the migration to handle schema updates.

fun migration(migration: AutomaticSchemaMigration, resolveEmbeddedObjectConstraints: Boolean = false): RealmConfiguration.Builder

Sets the migration to handle schema updates with automatic migration of data.

Link copied to clipboard
open override fun name(name: String): RealmConfiguration.Builder

Sets the filename of the realm file.

Link copied to clipboard

Sets the schema version of the Realm. This must be equal to or higher than the schema version of the existing Realm file, if any. If the schema version is higher than the already existing Realm, a migration is needed.