Im using
// this is a DefaultHttpClient
List<Cookie> cookies = this.getCookieStore().getCookies();
Now, since Cookie does not implement serializeable, I can’t serialize that List.
EDIT: (specified my goal, not only the problem)
My goal is to use the DefaultHttpClient with persistent cookies.
Anyone with experience that could lead me on the right track here? There might be another best practice that I haven’t discovered…
Create your own
SerializableCookieclass whichimplements Serializableand just copy theCookieproperties during its construction. Something like this:Ensure that all properties itself are also serializable. Apart from the primitives, the
Stringclass for example itself alreadyimplements Serializable, so you don’t have to worry about that.Alternatively you can also wrap/decorate the
Cookieas atransientproperty (so that it doesn’t get serialized) and override thewriteObject()andreadObject()methods accordingly. Something like:Finally use that class instead in the
List.