If you want to keep it around medium term or time frame, less than
permanent but
longer longer than the life of a particular activity, you can hold
onto it on an
Application class object.  That will stick around as long as the
application is
loaded and you can easily get to it from any of your activities.

Tim

On Jul 3, 1:32 pm, Mark Murphy <[email protected]> wrote:
> On Sat, Jul 3, 2010 at 1:28 PM, jul <[email protected]> wrote:
> > I created a RestaurantList class to hold my data (a list of some
> > Restaurant objects created to get some json data using gson). How can
> > I pass an instance of that class to onSaveInstanceState to be able to
> > restore my data when needed?
>
> You shouldn't pass an instance of that class to onSaveInstanceState().
> Your data model is not part of your instance state.
>
> If you are trying to deal with orientation changes, return your
> RestaurantList in onRetainNonConfigurationInstance() and get it back
> in onCreate() via getLastNonConfigurationInstance().
>
> Otherwise (or perhaps even if orientation is your issue), move that
> data out of the activity into a database, or in a pinch a Java object
> mediated by a service (so it will stick around despite activities
> coming and going).
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android 2.2 Programming Books:http://commonsware.com/books

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