How to Serialize TrueFalse Class and Store in Bundle?


#1

I am trying to complete the third challenge a bit differently than the other folks here. I understand how to make a separate array that is easily stored/read from the instance state bundle. I have added a Cheater private var to the TrueFalse array and am trying to get the array stored/read form the bundle.

I saw the put.Serializable method and have made TrueFalse serializable by adding “implements Serializable” and the requisite version number, but that makes it work for a single class element, not for storing the entire array in the bundle.

I am a bit at an end - how can I store the entire array in one shot? do I need to go in the parcel direction? Any advise is appreciated. I need this because I want to get a better grasp of persisting all sorts of data types beyond the basic ones in bundles etc.

Thanks in advance, and I love the book!


#2

OK I solved it but I had to simply use a loop and store each array entry as a serializable and give them each a different key. Sure would be nice to just be able to copy a whole array. As an old C programmer I yearn for the simple days of the memcpy() hammer!

Still would like to know what other alternatives there are though and how they compare (parcelable etc)…


#3

ArrayList implements Serializable, so you can just stash the entire thing in one go.

(and thanks!)