copyToRealm

abstract fun <T : RealmObject> copyToRealm(instance: T): T

Creates a copy of an object in the Realm.

This will create a copy of an object and all it's children. Any already managed objects will not be copied, including the root instance. So invoking this with an already managed object is a no-operation.

Return

the managed version of the instance.

Parameters

instance

the object to create a copy from.

Throws

if the class has a primary key field and an object with the same primary key already exists.