writeCopyTo

abstract fun writeCopyTo(targetConfiguration: Configuration)

Writes a compacted copy of the Realm to the given destination as defined by the targetConfiguration. The resulting file can be used for a number of purposes:

  • Backup of a local realm.

  • Backup of a synchronized realm, but all local changes must be uploaded first.

  • Convert a local realm to a partition-based realm.

  • Convert a synchronized (partition-based or flexible) realm to a local realm.

Encryption can be configured for the target Realm independently from the current Realm.

The destination file cannot already exist.

Parameters

targetConfiguration

configuration that defines what type of backup to make and where to write it by using Configuration.path.

Throws

if targetConfiguration has Flexible Sync enabled and the Realm being copied doesn't.

if this Realm is a synchronized Realm, and not all client changes are integrated in the server.