We LOVE to help with any issues or bug you have!
Questions: Caused by: java.lang.IllegalArgumentException: Each element of 'value' must be a valid managed object.
When Iuse it like this
Version of Realm and tooling
Realm version(s): 2.0.2
At first, showMarker seems to be an managed object.
You don't need to invoke copyToRealm() against managed object since it is a method for unmanaged object.
If RealmList from getImgs() contains unmanaged object, replace it with managed object before setting the list.
So the code should be something like:
realm.beginTransaction();
RealmList<Image> list = imageShow.getImgs();
if (!list.isManaged()) { // if the 'list' is managed, all items in it is also managed
RealmList<Image> managedImageList = new RealmList<>();
for (Image item : list) {
if (item.isManaged()) {
managedImageList.add(item);
} else {
managedImageList.add(realm.copyToRealm(item));
}
}
list = managedImageList;
}
showMarker.setImgs(list);
realm.commitTransaction();
And it's better to use executeTransaction() instead of beginTransaction()/commitTransaction().
OK thanks
Most helpful comment
At first,
showMarkerseems to be an managed object.You don't need to invoke
copyToRealm()against managed object since it is a method for unmanaged object.If
RealmListfromgetImgs()contains unmanaged object, replace it with managed object before setting the list.So the code should be something like:
And it's better to use
executeTransaction()instead ofbeginTransaction()/commitTransaction().