How to use Realm for Android like a champ, and how to tell if you’re doing it wrong
Zhuinden
1048
Hello I’m new on Realm, I’d like your feedback on this code. First i was using try with resources and inside execute an async task, then i changed to this:
Realm instance = Realm.getInstance(mRealmConfiguration);
instance.executeTransactionAsync(realm -> {
for (UserEntity entity : realm.where(UserEntity.class).equalTo(Fields.ACTIVE, true).findAll()) {
entity.setActive(false);
}
}, instance::close, error -> instance.close());
So for async stuff, try with resources is not a good thing, right?