title: Android: Any shortcut to Serializable from Parcelable without using marshall()?
body: <p>I'm aware of the performance differences between <code>Parcelable</code> (fast) and <code>Serializable</code> (slow). However, I need to store certain application information persistently, not just within one lifecycle, thus onSaveInstanceState and associated methods utilising Parcelable objects aren't appropriate.</p>
  <p>So I turned my attention to <code>Serializable</code>. Primarily I have <code>AbstractList</code> types to store - which is fine, since they implement <code>Serializable</code>. However, many of the types I store inside these are <code>Parcelable</code> but not <code>Serializable</code>, e.g. <code>RectF</code>.</p>
  <p>I thought &quot;no problem&quot;, since I can easily generate a Parcel via <code>Parcelable.writeToParcel(parcel, flags)</code> then call <code>marshall()</code> on it to create a <code>byte[]</code> which I can serialize and deserialize. I figured I'd use generics; create a <code>SerializableParcelable&lt;Parcelable&gt; implements Serializable</code> class, allowing a one-fit solution for all <code>Parcelable</code> types I wish to serialize. Then I would e.g. store each RectF inside this wrapper within <code>ArrayList</code>, and lo-and-behold the list and its <code>Parcelable</code> contents are serializable.</p>
  <p>However, the API docs state that <code>marshall()</code> mustn't be used for persistent storage:</p>
  <blockquote>
  <p><strong>public final byte[] marshall ()</strong></p>
  <p>Returns the raw bytes of the parcel.</p>
  <p><em>The data you retrieve here <strong>must not</strong> be placed in any kind of persistent storage (on local disk, across a network, etc). For that, you should use standard serialization or another kind of general serialization mechanism. The Parcel marshalled representation is highly optimized for local IPC, and as such does not attempt to maintain compatibility with data created in different versions of the platform.</em></p>
  </blockquote>
  <p>So now I'm stuck. I can either ignore this warning and follow the route I've outlined above, or else circumvent the issue by extending each individual <code>Parcelable</code> I want to serialize and creating bespoke serialization methods, which seems extremely wasteful of time and effort.</p>
  <p>Does anyone know of a 'correct' shortcut to serialize a <code>Parcelable</code> object without using <code>marshall()</code>? Or should I plough on without heeding the warning specified? Perhaps an SQLite database is the way to go, but I'm unsure and would like your advice.</p>
  <p>Many thanks.</p>