How do I pass an ArrayList of arrays to an intent in Android? I know you can pass an ArrayList<String>, but is it possible to pass an ArrayList<String[]>?
1 Answer
It's possible, but you need to pass it as a Serializable and you'll need to cast the result when you extract the extra. Since ArrayList implements Serializable and String[] is inherently serializable, the code is straightforward. To pass it:
ArrayList<String[]> list = . . .;
Intent i = . . .;
i.putExtra("strings", list);
To retrieve it:
Intent i = . . .;
ArrayList<String[]> list = (ArrayList<String[]>) getSerializableExtra("strings");
You'll have to suppress (or live with) the unchecked conversion warning.