Realm.io完成回调
Realm.io complete callback
我正在使用 Realm 来保存我的数据。在写入数据库时,我找不到任何方法来获得完整或失败的回调?
有什么方法可以知道领域何时完成?
据我所知,Realm-Java 不是异步的。 write data 的经典方法是在该事务期间使用写入事务和 creating/modifying 一个对象:
realm.beginTransaction();
User user = realm.createObject(User.class); // Create a new object
user.setName("John");
user.setEmail("john@corporation.com");
realm.commitTransaction();
来自 Realm-Java API 的 commitTransaction
:
All changes since beginTransaction() are persisted to disk and the Realm reverts back to being read-only. An event is sent to notify all other realm instances that a change has occurred. When the event is received, the other Realms will get their objects and RealmResults updated to reflect the changes from this commit.
我相信提交是原子的,只有成功或失败。如果失败,您将获得异常。代码一出现returns,数据已保存
我正在使用 Realm 来保存我的数据。在写入数据库时,我找不到任何方法来获得完整或失败的回调?
有什么方法可以知道领域何时完成?
Realm-Java 不是异步的。 write data 的经典方法是在该事务期间使用写入事务和 creating/modifying 一个对象:
realm.beginTransaction();
User user = realm.createObject(User.class); // Create a new object
user.setName("John");
user.setEmail("john@corporation.com");
realm.commitTransaction();
来自 Realm-Java API 的 commitTransaction
:
All changes since beginTransaction() are persisted to disk and the Realm reverts back to being read-only. An event is sent to notify all other realm instances that a change has occurred. When the event is received, the other Realms will get their objects and RealmResults updated to reflect the changes from this commit.
我相信提交是原子的,只有成功或失败。如果失败,您将获得异常。代码一出现returns,数据已保存