My problem is that I have an arraylist of arraylists with custom objects that needs to be passed from one activity to another.
Clearly, let's say I have something like:
ArrayList<ArrayList<Statement>> data;
in one activity and I want to pass it to another. So, first what I have done is to make Statement implement the Parcelable class. Then in the first activity (sender) I call the putExtra() method by passing it the data. In the second activity (receiver) I call the getSerializableExtra() method to get data.
That works. But I have read that Parcelable would be better for efficiency etc. and so I tried to call putParcelableArrayListExtra() in the sender activity and the getParcelableArrayListExtra() method on the receiver activity. But when I do that, I get red underlines indicating sth. like
ArrayList< android.os.Parcelable > is required
in the first activity which is the sender I have the line:
Intent intent = new Intent(SenderActivity.this, ReceiverActivity.class);
intent.putParcelableArrayListExtra(SenderActivity.EXTRA_LISTOFSTATEMENTLISTS, dataListOfStatementLists);
In the receiver activity I have sth. like:
myList = ( ArrayList<ArrayList<Statement>>) getIntent().getParcelableArrayListExtra(EXTRA_LISTOFSTATEMENTLISTS);
What I need to fix ? I know the basics about how to send Parcelable objects from one activity to another. But that was all things like
ArrayList<ParcelableObject> data
I have never done it for nested data like this
ArrayList<ArrayList<ParcelableObject>>
I hope someone can help.
Thanks in advance