Is it safe to use ActiveRecord pattern with Realm?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 18:12:08

问题


I'm building a little Android app and I find the ActiveRecord pattern pretty handy. But since ActiveAndroid development is quite dead, I turned to Realm instead.

I'm surprised nothing is said about this pattern, is it safe to write something like this ?

public void delete(){
    Realm realm=Realm.getDefaultInstance();
    realm.executeTransaction(new Realm.Transaction() {
        @Override
        public void execute(Realm realm) {
            MyClass.this.deleteFromRealm();
        }
    });
    realm.close();
}

来源:https://stackoverflow.com/questions/43169887/is-it-safe-to-use-activerecord-pattern-with-realm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!