我有一个要应用迁移的Realm模型。但是,当我应用迁移时,我得到了错误
Configurations cannot be different if used to open the same file.
The most likely cause is that equals() and hashCode() are not overridden in the migration class:
Run Code Online (Sandbox Code Playgroud)
在我的Activity类中,配置设置为:
realmConfiguration = new RealmConfiguration
.Builder(this)
.schemaVersion(0)
.migration(new Migration())
.build();
Run Code Online (Sandbox Code Playgroud)
我使用领域实例来获取一些值。然后我使用以下方法应用迁移:
RealmConfiguration config = new RealmConfiguration.Builder(this)
.schemaVersion(1) // Must be bumped when the schema changes
.migration(new Migration()) // Migration to run
.build();
Realm.setDefaultConfiguration(config);
Run Code Online (Sandbox Code Playgroud)
当我打电话给realm = Realm.getDefaultInstance();我时:我得到上面的错误。我是否正确应用了迁移?