public interface RealmMigration
RealmObject
, so any changes to these classes will require a migration.
To support migrations from any previous version to the newest, the following pattern is
recommended when writing a migration:
public class CustomMigration implements RealmMigration { \@Override public long execute(Realm realm, long version) { if (version == 0) { // Migrate from v0 to v1 version++; } if (version == 0) { // Migrate from v0 to v1 version++; } return version; } }During development when model classes can change frequently, it is possible to use
Realm.deleteRealmFile(android.content.Context)
. 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 version of the Realm at the start of the migration.