Hunt Hunt - 12 days ago 7
Android Question

realm with parceler to pass data across activities and services

I am using parceler with realm to pass data from activity to service.
i have few restrictions of realm and parceler

Restrictions

There are some important restrictions to be aware of when using Parceler:


  1. If you model contains a RealmList you need to register a special adapter.

  2. Once an object has been parcelled, it becomes detached from Realm and at this point behaves like an unmanaged object containing a snapshot of the data.Further changes to this object will not be persisted in Realm



for rule 1 i have register a special adapter for it , but for rule 2 i have a doub that at what point realm got deatched

is it at the time of annoting a class i.e. using

@Parcel(value = org.parceler.Parcel.Serialization.BEAN, analyze = { VisitInfo.class })


or at the time of unwrapping and wrapping

RequestInfo requestInfo = Parcels.unwrap(intent.getParcelableExtra("visitData"));

Answer

It becomes an unmanaged copy when you call Parcels.wrap() in the first place.

Realm by default expects you to send the primary key of the object over in the intent, and to requery it in the other Activity.

Comments