Sale
이라는 영역 클래스가 있습니다. 판매 클래스에 allSales
이라는 객체 목록이 있습니다. 이제 Sale
영역 클래스의 일부 객체를 삭제하고 싶습니다.영역 데이터베이스에서 영역 목록을 삭제하는 방법
RealmResults<Sale> allSales = realm.where(Sale.class).findAll();
RealmList<Sale> toBeDeleted = new RealmList<Sale>();
for(Sale sale : allSales){
String salesDate = sale.getSaleDate();
if(salesDate.equals("01-01-2017")) {
toBeDeleted.add(realm.copyToRealm(sale));
}
}
realm.beginTransaction();
toBeDeleted.clear();
realm.commitTransaction();
데이터는 Sale
클래스 대신에서만 삭제 toBeDeleted
목록에서 삭제되지 않았습니다.
합니다. –
저는 렐름 데이터베이스 버전 0.87.4를 사용하고 있습니다. –
왜 최신 버전이 3.1.4 일 때 0.87.4를 사용하고 있습니까 (btw는'clear()'을 찾고, https://realm.io/ docs/java/0.87.4/api/io/realm/RealmList.html) – EpicPandaForce