Reputation: 35
Using this code to pass the paths of some files, but my problem is how to get on the other activity,each path one by one ?
Thank you.
ArrayList<Uri> files3 = new ArrayList<Uri>();
for (int i = 0; i < thumbnailsselection.length; i++) {
if (thumbnailsselection[i]) {
File file = new File(filePaths.get(i).getPath());
files3.add(Uri.fromFile(file));
}
}
Intent intentmove = new Intent(getActivity(), Main.class);
intentmove.putExtra("files", files3.toString());
startActivity(intentmove);
Upvotes: 0
Views: 861
Reputation: 1562
In first Activity,
Intent intentmove = new Intent(getActivity(), Main.class);
intentmove.putParcelableArrayListExtra("files", files3);
startActivity(intentmove);
And in next activity,
ArrayList<Parcelable> uris =
getIntent().getParcelableArrayListExtra("files");
for (Parcelable p : uris) {
Uri uri = (Uri) p;
}
Upvotes: 1
Reputation: 1954
Use this code is second activity
String path1=getIntent().getStringExtra("file1");
String path2=getIntent().getStringExtra("file2");
String path3=getIntent().getStringExtra("file3");
Upvotes: 0
Reputation: 2814
pass them as an Array of Strings.
intentmove.putExtra("files", ** Array of Files goes here **);
Get them with:
getIntent().getStringArrayExtra("files");
Upvotes: 0