android parcelable string array

14,748

Solution 1

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

Solution 2

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

ArrayList<String> ids = new ArrayList<String>();
savedInstanceState.putStringArrayList("key",ids);
Share:
14,748
Saideira
Author by

Saideira

Contract developer, worked on everything from MIPS assembly to financial J2EE systems. I wish to go work on Mars. Or Australia.

Updated on June 04, 2022

Comments

  • Saideira
    Saideira almost 2 years

    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.

  • XåpplI'-I0llwlg'I  -
    XåpplI'-I0llwlg'I - over 11 years