這是我的刪除功能和它找到workday1
對象:的Android realm.io:行/對象不再有效
public static void delete(Context context, Workday workday) {
Realm realm = getRealm(context);
realm.beginTransaction();
Workday workday1 = realm.where(Workday.class)
.equalTo("date", workday.getDate())
.equalTo("hours", workday.getHours())
.equalTo("minutes", workday.getMinutes())
.findFirst();
workday1.removeFromRealm();
realm.commitTransaction();
}
當執行removeFromRealm
方法崩潰:
java.lang.IllegalStateException: Illegal State: Row/Object is no longer valid to operate on.
被刪除?
我該如何解決這個問題?任何幫助將不勝感激。
UPDATE(我可以打印通過以下方法返回的內容):
Workday workday1 = realm.where(Workday.class)
.equalTo("date", workday.getDate())
.equalTo("hours", workday.getHours())
.equalTo("minutes", workday.getMinutes())
.findFirst();
System.out.println("--------------------------------");
System.out.println(workday1.getHours());
你可以在removeFromRealm()之前訪問對象嗎?例如打印它? – bmunk 2014-12-08 08:38:14
是的,我可以,請檢查我的更新。 – Jdruwe 2014-12-08 19:11:12
如果這是你可以複製的東西,我建議你在https://github.com/realm/realm-java/issues創建一個github問題 – bmunk 2014-12-09 18:11:09