I am having 2 String arrays inside First Activity - A , now i need to pass both the arrays to the second_activity - B, how do i do it ?
I know about the Intent
kind of concept in Android and already passed just single variable value to another activity, but i haven't implement the concept of passing string arrays between activities, i have already surfed net for the same.
pls let me know about the possible solution.
putStringArray(key, new String[]{value1, value2}); Intent i=new Intent(context, Class); i. putExtras(b); Hope this will help you. it is just a name with which you want to catch your array in another activity......
Bundle b=new Bundle(); b.putStringArray(key, new String[]{value1, value2}); Intent i=new Intent(context, Class); i.putExtras(b);
Hope this will help you.
In order to read:
Bundle b=this.getIntent().getExtras(); String[] array=b.getStringArray(key);
Not directly an answer to the question but you can also use .putStringArrayListExtra() in your bundle. It is more flexible than sending string array.
Bundle b=new Bundle(); b.putStringArrayListExtra("URL_ARRAY_LIST", myStringArrayList); Intent i=new Intent(context, Class); i.putExtras(b);
Then you can get this arrayList as follows:
ArrayList<String> urls; urls = getIntent().getStringArrayListExtra("URL_ARRAY_LIST");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With