initialDataCallback

Callback that will be triggered in order to write initial data when the Realm file is created for the first time.

The callback has a MutableRealm] as a receiver, which allows for the following pattern:

val config = RealmConfiguration.Builder()
.initialData { // this: MutableRealm
copyToRealm(Person("Jane Doe"))
}
.build()
val realm = Realm.open(config)

Return

null if no initial data should be written when opening a Realm file, otherwise the callback return is the one responsible for writing the data.

See also