我有一行返回带有一些排序数据的 RealmResult。
我想以最快最简单的方式删除所有这些项目。例如:
RealmResults<ElementEntry> currentElements = realm.where(ElementEntry.class).equalTo("type", 1).findAll();
//something like this then, would be preffered:
currentElements.removeFromRealm();
但是我必须使用迭代器什么的,但是当我尝试这样做时,我得到了这个错误:
java.util.ConcurrentModificationException: No outside changes to a Realm is allowed while iterating a RealmResults. Use iterators methods instead.
如果不是应该使用的迭代器,那么我可以使用什么?
最佳答案
尝试清除方法
来自文档:
Removes all objects from the list. This also deletes the objects from the underlying Realm.
@throws IllegalStateException if the corresponding Realm is closed or in an incorrect thread.
realm.beginTransaction();
currentElements.clear()
realm.commitTransaction();
关于java - 我怎样才能最快最简单地删除 RealmResults 列表中的所有项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35040599/