This is one of the interesting tensions resulting from the Google decision to implement the Java language on the phone, in such a limited environment. For Serializable IS the "Java way" of approaching the problem. But as Dianne says, it is inefficient, woefully so in a mobile phone environment. So it really should not be used in Android. Just as Dianne says, Parcelable should be used instead, despite the extra effort.
But I am sure many will continue to act based on the instincts they learned from Java SE or EE and try to use Serializable. So we have to keep repeating it, ad nauseum if need be: use Parcelable instead, despite the extra initial effort. Then again, there is another interesting question here: why is the OP doing his own custom (un)marshalling in the first place? Does he really need it, or is he just unaware of how to use classes already in Android for that task? On Sep 18, 11:17 am, Dianne Hackborn <[email protected]> wrote: > Please do *not* use Serializable. It is really inefficient. > > If you want to implement custom marshalling/unmarshalling, implement > Parcelable. It requires that you do more work, but it is far more > efficient. > > On Sat, Sep 18, 2010 at 3:57 AM, YuviDroid <[email protected]> wrote: > > I haven't played with this, but if you make your class (myArrayType) > > implement > > the Serializable interface it should work fine. Of course, all the instance > > variables of that class must also be Serializable, otherwise you would still > > get an exception (probably a NotSerializableException). > > > Hope it helps, > > Yuvi > > > On Sat, Sep 18, 2010 at 12:46 PM, [email protected] < > > [email protected]> wrote: > > >> I have 2 dimensions array like this: > >> public myArrayType[][] mObjArray; > > >> I want to save it in the onSaveInstanceState method, since my array > >> contains lot of elements I dont want to save element by element but > >> the whole array object, what is the best way? > > >> I tried this but exception is thrown: > > >> --------------------------------------------------------- > > >> public Bundle saveState(Bundle map) { > > >> if (map != null) { > >> map.putSerializable("objLevel", (Serializable) > >> mCurrentLevelMatrix); > >> } > > >> return map; > >> } > > >> ------------------------------------------------------- > > >> I have seen a putParcelableArrayList method but dunno how it works > >> exactly. > > >> -- > >> You received this message because you are subscribed to the Google > >> Groups "Android Developers" group. > >> To post to this group, send email to [email protected] > >> To unsubscribe from this group, send email to > >> [email protected]<android-developers%[email protected]> > >> For more options, visit this group at > >>http://groups.google.com/group/android-developers?hl=en > > > -- > > YuviDroid > > Check out Launch-X <http://android.yuvalsharon.net/launchx.php> (a widget > > to quickly access your favorite apps and contacts!) > >http://android.yuvalsharon.net > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

