This is Realm Java so I'm doing
realm.beginTransaction();
realm.deleteAll();
realm.commitTransaction();
I have 20 or so Realm
classes. I only want to keep one.
Instead of doing
realm.beginTransaction();
realm.delete(Table1.class);
realm.delete(Table2.class);
realm.delete(Table3.class);
...
realm.commitTransaction();
Is there a way to delete all tables except one?
"deleteAll.except(Table12.class)" etc?
thanks!
Sure!
final RealmConfiguration realmConfiguration = realm.getConfiguration();
r.executeTransaction((realm) -> {
for(Class<? extends RealmModel> clazz : realmConfiguration.getRealmObjectClasses()) {
if(clazz != Table12.class) {
realm.delete(clazz);
}
}
});