public class IncompatibleSyncedFileException extends RealmFileException
getBackupRealmConfiguration()
to obtain a RealmConfiguration that can then be used to open the backup Realm. After that, retry
opening the original Realm file (which now should be recreated as an empty file) and copy all data from the backup file to the new one.
SyncConfiguration syncConfig = new SyncConfiguration.Builder(user, serverUri).build();
try {
Realm realm = Realm.getInstance(syncConfig);
} catch (IncompatibleSyncedFileException exception) {
RealmConfiguration backupConfig = exception.getBackupRealmConfiguration();
Realm backupRealm = Realm.getInstance(backupConfig);
realm = Realm.GetInstance(syncConfig);
}
RealmFileException.Kind| Constructor and Description |
|---|
IncompatibleSyncedFileException(String message,
String recoveryPath) |
| Modifier and Type | Method and Description |
|---|---|
RealmConfiguration |
getBackupRealmConfiguration()
Gets a
RealmConfiguration instance that can be used to open the backup Realm file. |
RealmConfiguration |
getBackupRealmConfiguration(byte[] encryptionKey)
Gets a
RealmConfiguration instance that can be used to open the backup Realm file. |
RealmConfiguration |
getBackupRealmConfiguration(byte[] encryptionKey,
Object... modules)
Gets a
RealmConfiguration instance that can be used to open the backup Realm file. |
String |
getRecoveryPath() |
getKind, toStringaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTracepublic RealmConfiguration getBackupRealmConfiguration()
RealmConfiguration instance that can be used to open the backup Realm file.
Note: This will use the default Realm module (composed of all RealmModel), and
assume no encryption should be used as well.public RealmConfiguration getBackupRealmConfiguration(byte[] encryptionKey)
RealmConfiguration instance that can be used to open the backup Realm file.
Note: This will use the default Realm module (composed of all RealmModel).encryptionKey - Optional encryption key that was used to encrypt the original Realm file.public RealmConfiguration getBackupRealmConfiguration(byte[] encryptionKey, Object... modules)
RealmConfiguration instance that can be used to open the backup Realm file.encryptionKey - Optional encryption key that was used to encrypt the original Realm file.modules - restricts Realm schema to the provided module.public String getRecoveryPath()