abstract class SharedBuilder<T, S : Configuration.SharedBuilder<T, S>>(schema: Set<KClass<out BaseRealmObject>> = setOf())

Base class for configuration builders that holds properties available to both RealmConfiguration and SyncConfiguration.



the type of Configuration the builder should generate.


the type of builder, needed to distinguish between local and sync variants.



Link copied to clipboard
constructor(schema: Set<KClass<out BaseRealmObject>> = setOf())


Link copied to clipboard
abstract fun build(): T

Creates the RealmConfiguration based on the builder properties.

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

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

Link copied to clipboard
fun encryptionKey(encryptionKey: ByteArray): S

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): S

Initializes a realm file with a bundled asset realm file.

Link copied to clipboard
fun inMemory(): S

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
fun maxNumberOfActiveVersions(maxVersions: Long = 8): S

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
abstract fun name(name: String): S

Sets the filename of the realm file.

Link copied to clipboard
fun schemaVersion(schemaVersion: Long): S

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.