So I have this little cable that you plug into your phone that has a USB port on the other side where you can plug in a flash drive for example, as you can see here:
When I plug in a flash drive I get a notification that says:
USB mass storage connected
When I then launch a file explorer app I can see that the drive is then located at:
/storage/UsbDriveA/
And that's great, but I want to know how to gain access to the flash drive in my code. Getting access to the SD card is easy enough:
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard.getAbsolutePath() + "/MyFiles")
directory.mkdirs();
But how would you do this in the case of the flash drive? Thanks in advance! :)
I can't test this, not having such a cable myself, but my assumption would be that you can pass your filepath directly into the constructor which would look like:
Have you tried this?
In this example I am using the FileUtils from Apache, but event without it you will see the logic used to read a USB Flash drive:
In my manifest I have those lines, although I'm not sure they're all mandatory...