I am newB in Android. I was working on a problem where I came across passing custom object between Activity. I did some research and found that, if I need to either implement Serializable or Parcellable interface, I also found that Parcellable is faster compared to Serializable. But I am having confusion on, let's say I have multiple custom Object in my class as property then do I need to make all those Object to implement either or those interface or there is any other method to do that.
Forgive me if I am not clear, please feel free to edit if possible.
Thanks.
The simplest way to use them would be to make your class implement Serializable
, and make sure that every one of the class members also implement Serializable
(or is a base value like int).
If you have a member that does not implement Serializable
, you're going to have to implement the serialize/deserialize methods of our class manually.
Parcelable
is more efficient, but not as automatic as Serializable
.
Check out this blog on how to use Parcelable
:
http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/