Intent.putExtra List [duplicate]

Assuming that your List is a list of strings make data an ArrayList<String> and use intent.putStringArrayListExtra("data", data)

Here is a skeleton of the code you need:

  1. Declare List

     private List<String> test;
    
  2. Init List at appropriate place

     test = new ArrayList<String>();
    

    and add data as appropriate to test.

  3. Pass to intent as follows:

     Intent intent = getIntent();  
     intent.putStringArrayListExtra("test", (ArrayList<String>) test);
    
  4. Retrieve data as follows:

     ArrayList<String> test = getIntent().getStringArrayListExtra("test");
    

Leave a Comment