Home » Android » android – Passing ArrayList<MyObject> Between multiple Activities

android – Passing ArrayList<MyObject> Between multiple Activities

Posted by: admin June 15, 2020 Leave a comment


I am trying to pass an ArrayList of Objects between multiple activities in my application. Is it possible to do this using an Intent using the setData() method?

How to&Answers:

If you want to send an ArrayList of objects then your class must implement the Parcelable or Serializable interface .

See these good tutorials for sending custom object between Activities




Use below code for pass arraylist in intent.

Intent mIntent = new Intent(FirstActivity.this, SecondActivity.class);
mIntent.putParcelableArrayListExtra("Data", mArraylist);

Use below code For get arraylist from Intent.

Bundle bdl = getIntent().getExtras();
mArraylist1 = bdl.getParcelableArrayList("Data");


First you need to extend parcelable class in your Object class. Then you can pass it through intent via intent.putParcelableArrayListExtra("PASSING_DATA", data);

here data is arraylist of custom objects.

see Parcelable and Parcelable Tutorial for better undertanding


If the objects implement Parcelable you can use the putParcelableArrayList method like this:

Bundle data = new Bundle();
data.putParcelableArrayList("myArrayList", myList);
Intent i = new Intent();
i.putExtra("data", data);

Hope that helps.


yes, it is possible…
You need to implement Serializable class by your object class.


You can make the arraylist static where you are defining it, and only pass the position to the next activity