Take the 2-minute tour ×  I created an instance of a custom
class RestaurantList to hold my data (a list of restaurant data
received from a web service as json data).  How can I save it in
onSaveInstanceState?  share|improve this question add comment  3
Answers  up vote 13 down vote accepted  Custom objects can be
saved inside a Bundle when they implement the interface
Parcelable. Then they can be saved via:      public void
onSaveInstanceState(Bundle outState) {
outState.putParcelable("key", myObject);  Basically the
following methods must be implemented in the class file:
public class MyParcelable implements Parcelable {      private
int mData;       public int describeContents() {          return
0;       /** save object in parcel */      public void
writeToParcel(Parcel out, int flags) {       public static final
Parcelable.Creator<MyParcelable> CREATOR              = new
Parcelable.Creator<MyParcelable>() {          public
MyParcelable createFromParcel(Parcel in) {              return
new MyPar