Please don't do this, as the Parcelable documentation says, this is not
intended for persisting but only for IPC.  Future updates of the platform
can change the format (in fact I believe Donut will change Bundle's
parcelable format) and break your saved state.

You can use SharedPreferences for this, or you can use a raw file and the
standard Java APIs to read and write it in whatever format you want.

On Mon, Jul 27, 2009 at 2:23 PM, Mark Murphy <[email protected]>wrote:

>
> Robert Green wrote:
> > I'm well aware of onSaveInstanceState(Bundle b) and the corresponding
> > onCreate and onRestore...
> >
> > What I want to do is persist the bundle somewhere simple where I'll
> > only ever have one at a time.  The functionality is to be able to
> > resume a game from its previously stored state - not to be confused
> > with restoring the activity during its lifecycle.  I want to restore
> > it AFTER it's been destroyed (think of turning the phone on and having
> > a button on the game that says, "resume last game".  My thoughts are
> > that if I can just persist the bundle that I normally use for the
> > instance state, then I should be able to reload it later upon user
> > request.
> >
> > I don't want to use a provider because they seem way too over the top
> > for what I'm doing.  Anyone?
> >
> > The best functionality would be
> >
> > saveBundle(Bundle b)
> >
> > -game menu activity-
> > isThereASavedBundle()?
> > Bundle b = loadBundle();
> > startGameActivityWithResumeFlagOn();
>
> Bundle implements Parcelable, so you should be able to use
> writeToParcel()/readFromParcel() to get the Bundle into a Parcel, then
> use Parcel's marshall() and unmarshall() to get a byte[] you can persist
> to a file.
>
> Somewhat tedious, but it should work.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Looking for Android opportunities? http://wiki.andmob.org/hado
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to