Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting a Parcelable object in Android

I have a class in my Android app that I've made Parcelable so that it can be passed between Activities.

I would like to be able to save this object to the filesystem. It seems that since I've already implemented Parcelable, it would make sense to pipe the output of this to the filesystem and read it back later.

Is there a correct way to do this? Or must I implement both Parcelable and Serialiazble if I want to both pass the object between Activities and also save it to the filesystem?

like image 841
Matthew Avatar asked Dec 27 '22 14:12

Matthew


1 Answers

From http://developer.android.com/reference/android/os/Parcel.html

Parcel is not a general-purpose serialization mechanism. This class (and the corresponding Parcelable API for placing arbitrary objects into a Parcel) is designed as a high-performance IPC transport. As such, it is not appropriate to place any Parcel data in to persistent storage: changes in the underlying implementation of any of the data in the Parcel can render older data unreadable.

like image 100
K-ballo Avatar answered Jan 07 '23 23:01

K-ballo