title: How to pass List of list of objects from one activity to another
body: <p>I need to pass an arraylist which contains object with a string and arraylist. I am unable to pass the arraylist to other activity. In the Activity1 the list contains value that I have verified. </p>
  
  <p>DepositBn:</p>
  
  <pre><code>package support;
  
  import android.os.Parcel;
  import android.os.Parcelable;
  import com.google.gson.annotations.SerializedName;
  import java.util.ArrayList;
  
  public class DepositBn implements Parcelable {
  
  private String limit;
  @SerializedName("period")
  private ArrayList&lt;Rate&gt; rateList;
  
  protected DepositBn(Parcel in) {
      limit = in.readString();
  }
  
  public String getLimit() {
      return limit;
  }
  
  public void setLimit(String limit) {
      this.limit = limit;
  }
  
  public ArrayList&lt;Rate&gt; getRateList() {
      return rateList;
  }
  
  public void setRateList(ArrayList&lt;Rate&gt; rateList) {
      this.rateList = rateList;
  }
  
  public class Rate {
      private String rate;
  
      public String getRate() {
          return rate;
      }
  
      public void setRate(String rate) {
          this.rate = rate;
      }
  
  }
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeString(limit);
  }
  public static final Creator&lt;DepositBn&gt; CREATOR = new Creator&lt;DepositBn&gt;() {
      @Override
      public DepositBn createFromParcel(Parcel in) {
          return new DepositBn(in);
      }
  
      @Override
      public DepositBn[] newArray(int size) {
          return new DepositBn[size];
      }
  };
  </code></pre>
  
  <p>}</p>
  
  <p>In the Activity1:</p>
  
  <pre><code>@Override
      protected void onPostExecute(ArrayList&lt;DepositBn&gt; result) {
          super.onPostExecute(result);
          System.out.println("result = " + result);
          for (DepositBn depositBn : result) {
              System.out.println("----" + depositBn.getLimit());
          }
          try {
              Intent intent = new Intent(DepositRates.this, GenericRateDisplay.class);
              Resources res = DepositRates.this.getResources();
  
              Bundle bundle = new Bundle();
              bundle.putParcelableArrayList("depositBnArrayList",result);
              bundle.putString("pageName", res.getString(R.string.domesticRates));
              intent.putExtras(bundle);
  
  
              startActivity(intent);
          } catch (Exception ex) {
              ex.printStackTrace();
          }
      }
  </code></pre>
  
  <p>In Activity2:</p>
  
  <pre><code>package in.co.sbm.sbmvirtual;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  import java.util.ArrayList;
  
  import support.DepositBn;
  
  public class GenericRateDisplay extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_generic_rate_display);
  
      Bundle b = this.getIntent().getExtras();
  
      ArrayList&lt;DepositBn&gt; depositBnArrayList = b.getParcelableArrayList("depositBnArrayList");
      //String pageName = b.getString("pageName");
  
      ArrayList&lt;String&gt; rateList = new ArrayList();
  
      for (DepositBn depositBn : depositBnArrayList) {
          for(DepositBn.Rate rate : depositBn.getRateList()){
              rateList.add(rate.toString());
          }
      }
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(GenericRateDisplay.this,
              android.R.layout.simple_list_item_1, rateList);
      ListView listView = (ListView) findViewById(R.id.genericListView);
      listView.setAdapter(adapter);
  }
  </code></pre>
  
  <p>}</p>