1

I have a RealmObject which contains for example these fields:

@PrimaryKey
String id;

JustRealmObject justRealmObject;

@ParcelPropertyConverter(SomeRealmObjectParcelConverter.class)    
RealmList<SomeRealmObject> someRealmObjects;

ProblemRealmObject problemObject;

And with the first 3 fields everything is fine, they're wrapping and unwrapping as should when I pass the main RealmObject to another activity in an intent.

A ProblemRealmObject has next fields:

@PrimaryKey
String name;

@ParcelPropertyConverter(NeededRealmObjectParcelConverter.class)
RealmList<NeededRealmObject> neededRealmObjects;

And here I have a problem. The field name wraps/unwraps, but neededRealmObjects doesn't. I always get null when trying to get this list after unwrapping the main RealmObject. For a RealmList I use a RealmListParcelConverter and it works great if RealmList is inside the the main RealmObject, but it's not even calling in the case when the RealmList is in the ProblemRealmObject within the main RealmObject...

How can I resolve that?

blink7
  • 51
  • 6
  • Have you tried copying the object from the Realm first with 2 depth? – EpicPandaForce Sep 01 '17 at 21:15
  • @EpicPandaForce what do you mean? Copying the main object and the `ProblemRealmObject` separately and then insert the second into the first one and pass to an `Intent`? This will impose an additional complexity on the algorithm and passing a parcel object will lose its meaning... I use the `RealmRecyclerViewAdapter ` and clicking on an item in the list I already get the required object without having to refer to the database manually each time. – blink7 Sep 02 '17 at 06:31
  • No, like `realm.copyFromRealm(mainObject, 2)` although it might be 3. Although for sending data between activities, with Realm, passing primary key is preferred. – EpicPandaForce Sep 02 '17 at 06:38
  • @EpicPandaForce I don't use `copyFromRealm(...)` method because of using the `RealmRecyclerViewAdapter`, for which I pass a `RealmResults`. In any case, thank you for the reply, I'll pass a primary key since there is no another way. – blink7 Sep 02 '17 at 09:49

0 Answers0