Exporar ArrayList from one activity to another

0

I have an ArrayList called "answers" in an activity. And I want that, when in an activity where a survey is created, a certain question is answered, add the answer, which is in string, to the array "answers". But I can not because the array is not created in the survey activity. Thanks in advance!

    
asked by Pablo Gonzalez 06.03.2017 в 21:43
source

1 answer

1

Good mate @Pablo Gonzalez, if you want to pass an array of strings you can use the following example code fragment:

This will go into your main activity class:

String[] array1={"asd","fgh","dcf","dg","ere","dsf"};
Intent i=new Intent(MainActivity.this,MainActivity2.class);
i.putExtra("key",array1);
startActivity(i);

And you would receive it with the following in your other activity:

String[] array = getIntent().getStringArrayExtra("key");

I leave the link where you can see its English version, greetings.

How to pass a string array value

    
answered by 06.03.2017 в 22:02