Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store and retrieve array list in Bundle in Android

How do I store and retrieve an array list of values in a Bundle in Android? Any examples?

like image 403
mohan Avatar asked Nov 29 '10 12:11

mohan


1 Answers

Lets take if you array list has strings in it.

ArrayList<String> al = new ArrayList<String>();
al.add("test1");
al.add("test2");
al.add("test3");

Now you can put it into bundle as follows:

Bundle value= new Bundle();
value.putStringArrayList("temp1", al);

If you have your own object type instead of "String" in ArrayList then you need to serialize that ArrayList object.

like image 127
Umakant Patil Avatar answered Oct 30 '22 12:10

Umakant Patil