0

There is a lot of information out there concerning Parcelable in Android. After looking around, I couldn't find a nice solution for my problem.

So, I need to create a class (let's call it "MyClass") which extends a custom class someone else wrote ("HisClass"). There are many instance variables in HisClass, some of which are objects of custom classes, themselves. I want to pass a MyClass object from one activity to another and I realize, I need to make it Parcelable. But what about the instance variables which are custom objects?

Reading this, I think I need to make every single custom object implement Parcelable. Since, there are many custom objects in MyClass and HisClass which again have custom objects for instance variables, doing that seems like a bad solution to me.

Is there a better way? Maybe, I am just being totally blind here. Hope someone can help me.

Bashorings
  • 384
  • 3
  • 10

1 Answers1

0

Well, you can make use of Serializer, but it would result in a slow performance. AFAIK, implementing Parcelable is the best way to passing data. Additionally, don't try to complicate yourself by creating so much complex data structure to pass using Intent.

Either use Parcelable for something cheap/light-weight/less-in-amount or something else like output to files...and passing its paths.

Pete Houston
  • 14,931
  • 6
  • 47
  • 60
  • I have thought about using a file as temporary storage. But for security reasons, I would rather not do this. Confidential data is stored in those objects and I don't want this information to be stored in the file system. I could, of course, encrypt the data before writing it to a file, but I am not sure whether this would hurt the performance. – Bashorings Oct 05 '11 at 12:32