Search code examples
androidfilebundleparcelable

Adding List<File> to Bundle in Android


I have a Listof File's in Android.

List<File> images

And I need to put that into a bundle. I have been trying to convert them to Parcelable but I have not found a way to do that.

bundle.putParcelable(BundleKeys.IMAGES.name(), images);

File comes from the camera pictures.


Solution

  • Use this for passing:

    ArrayList<File> images; //Your list
    bundle.putSerializable(BundleKeys.IMAGES.name(), images);
    

    And use this for retrieving it:

    ArrayList<File> images = (ArrayList<File>) getIntent().getSerializableExtra(BundleKeys.IMAGES.name());