Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write and read ArrayList<String> to parcel in android

Tags:

android

In my project, I have to write and read ArrayList<String> to parcel, I tried with writeList and writeStringList but no use, I am getting exceptions while reading the lists.

Could any one help me in this?

Thanks In advance.

like image 456
Gopika Perumalla Avatar asked Apr 25 '13 05:04

Gopika Perumalla


2 Answers

By @JeremyRoman: writeStringList, readStringList and createStringArrayList all exist on Parcel since API 1.

like image 184
StoneBird Avatar answered Nov 11 '22 07:11

StoneBird


use this to write:

bundle.putStringArrayList(KEY, stringArrayList); 

and this to read:

ArrayList<String> stringArrayList = bundle.getStringArrayList(KEY);
like image 30
Oleksandr Bodashko Avatar answered Nov 11 '22 07:11

Oleksandr Bodashko