Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 821
Saideira Avatar asked Jul 20 '26 16:07

Saideira


2 Answers

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

like image 151
cement Avatar answered Jul 22 '26 06:07

cement


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

ArrayList<String> ids = new ArrayList<String>();
savedInstanceState.putStringArrayList("key",ids);
like image 42
blindstuff Avatar answered Jul 22 '26 06:07

blindstuff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!