Saideira
Saideira

Reputation: 2404

android parcelable string array

I have

ArrayList<String> ids = ArrayList<String>();

What would be the cleanest way to make it Parceleable? Apparently String itself is not parcelable, so Parcel.writeList(ids) is not working.

I was thinking to either parcelize ArrayList<Uri> or put array contents into a Bundle.

Upvotes: 2

Views: 15609

Answers (2)

blindstuff
blindstuff

Reputation: 18348

This isnt parcelizing, but to put it in a bundle:

ArrayList<String> ids = new ArrayList<String>();
savedInstanceState.putStringArrayList("key",ids);

Upvotes: 3

cement
cement

Reputation: 2905

Convert your list to String[] and use Parcel.writeStringArray. Example here

Upvotes: 6

Related Questions