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/commonsguy
http://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