public interface RealmMigration
RealmObject, so any changes to these classes will require a migration.
To support migrations from any previous schemaVersion to the newest, the following pattern is
recommended when writing a migration:
public class CustomMigration implements RealmMigration {
\@Override
public long execute(Realm realm, long schemaVersion) {
if (schemaVersion == 0) {
// Migrate from v0 to v1
schemaVersion++;
}
if (schemaVersion == 0) {
// Migrate from v0 to v1
schemaVersion++;
}
return schemaVersion;
}
}
During development when model classes can change frequently, it is possible to use
Realm.deleteRealm(RealmConfiguration). This will delete the database
file and eliminate the need for any migrations.| Modifier and Type | Method and Description |
|---|---|
long |
execute(Realm realm,
long version)
Implement this method in your subclass to perform migration.
|
long execute(Realm realm, long version)
realm - The Realm on which to perform the migration.version - The schemaVersion of the Realm at the start of the migration.