2

I have a ArrayList documents and I want to send this file to another Activity. but How to get This value in SecondActivity

What I tried is In First Activity

 private ArrayList<File> documents;
Intent selectLabInt = new Intent(FirstActivity.this, SecondActivity.class);

 selectLabInt.putExtra("patient_name", patientNameStr);
 selectLabInt.putExtra("referal_notes", referalNotesStr);
 selectLabInt.putExtra("fileList",documents);

 startActivity(selectLabInt);
Sabya Sachi
  • 145
  • 2
  • 10

2 Answers2

3

If your File is serializable,then you can pass the ArrayList like this:

In the sending Activity:

ArrayList<File> documents= new ArrayList<File>();
intent.putExtra("documents", documents);

In the receiving Activity:

ArrayList<File> documents = (ArrayList<File>)getIntent().getSerializableExtra("documents");
Jas
  • 3,207
  • 2
  • 15
  • 45
0

You need to make File class parcelable so that you can pass arraylist of that class in intent via putParcelable.

here is example of same https://stackoverflow.com/a/6681784/942224

Community
  • 1
  • 1
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75