Builder

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

Constructors

Builder
Link copied to clipboard
fun Builder(schema: Set<KClass<out RealmObject>> = setOf())

Functions

build
Link copied to clipboard
fun build(): RealmConfiguration

Creates the RealmConfiguration based on the builder properties.

deleteRealmIfMigrationNeeded
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.

encryptionKey
Link copied to clipboard
fun encryptionKey(encryptionKey: ByteArray): RealmConfiguration.Builder

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

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

Configure how Realm will report log events.

maxNumberOfActiveVersions
Link copied to clipboard
fun maxNumberOfActiveVersions(maxVersions: Long = 8): RealmConfiguration.Builder

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

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

Sets the filename of the realm file.

path
Link copied to clipboard
fun path(path: String?): RealmConfiguration.Builder

Sets the absolute path of the realm file.

schema
Link copied to clipboard
fun schema(vararg classes: KClass<out RealmObject>): RealmConfiguration.Builder
fun schema(classes: Set<KClass<out RealmObject>>): RealmConfiguration.Builder

Sets the classes of the schema.

schemaVersion
Link copied to clipboard
fun schemaVersion(schemaVersion: Long): RealmConfiguration.Builder

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.

Properties

schema
Link copied to clipboard
var schema: Set<KClass<out RealmObject>>