我想在迁移过程中删除特定表的条目(旧对象将不再相关)。
我该如何正确地做到这一点?我可以致电delete()
,还是需要拨打beginTransaction()
和endTransaction()
?
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
RealmSchema schema = realm.getSchema();
if(oldVersion < 4) {
// do the migration here
realm.delete("ChartObject"); // is this correct for deleting all ChartObjects?
oldVersion = 4;
}
}