Android Parcel: Writing an array list

61 Views Asked by At

Does writing an ArrayList to a parcel create a copy of the list when you read it back? My custom objects are Parcelable and I make sure I don't create copies. I need to be able to pass an ArrayList forward to other activities through intents and I need to be able to add and remove elements in the ArrayList in other activities.

Right now it seems like Parcel creates a copy of the ArrayList therefore I am not able to easily update the elements.

1

There are 1 best solutions below

0
On

Using Parcel serializes and deserializes the data. This makes copies. If you need to share the original objects then you can declare references to them as static, which can be accessed from all classes.