I am replacing ORMLite
with Realm
in my project.
We have RealmQuery
for QueryBuilder
What is similar for DeleteBuilder
?
How can I replace DeleteBuilder query with Realm API
To my knowledge Realm just support to delete the Table and Database itself. What if when I have to delete record with some query (as we can do with DeleteBuilder)
There is not a DeleteBuilder as such, instead we have removal methods on most Realm classes:
Foo obj = realm.where(Foo.class).findFirst(); // Find a single object;
obj.deleteFromRealm(); // Delete the object from Realm
RealmResults<Foo> list = realm.where(Foo.class).findAll(); // Find all objects;
list.deleteAllFromRealm(); // delete all items that matched your query
list.deleteFromRealm(0); // Delete item at specific index.
realm.delete(Foo.class); // delete all Foo's
realm.deleteAll(); // delete all data in Realm but preserve the schema
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.