Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android parcel, stored in memory or on disk? How to store on disk

I see parcel and serializable being used kind of interchangeably, or at least un-intuitively in the same context. Can you clarify some things for me?

  1. are parcel's persistent storage (on the disk) or stored in memory only

  2. do I need serializable to store parcel data to disk

thank you for the insight, and no, the android dev manual does not make this obvious to me

like image 305
CQM Avatar asked Oct 12 '25 15:10

CQM


1 Answers

My answers:

  1. Parcels are for flattening objects so they can be stored somewhere other than the JVM's running memory.

  2. You do not need to mix serializable with parcels to store data to disk. One or the other alone is enough to store objects to disk.


Serializable and Parcelable are both ways to flatten your Java objects.

These flattened objects can be passed between processes via various transmission formats -- disk files included.

Serializable comes from core Java and is easy to use.

Parcelable comes from Android and is a little more complex.

This answer includes more details:

https://stackoverflow.com/a/5551155/523135

This blog post has sample code Parcelable:

http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/

This blog post has sample Serializable code:

http://www.javapractices.com/topic/TopicAction.do?Id=45

like image 91
Cory Trese Avatar answered Oct 14 '25 07:10

Cory Trese