5

I have sony tablet S and I am connecting a pendrive to it.

I have found code that lets me:

  • -Find the connected device

  • -Find its interfaces

  • -Find its endpoints (read, write)

  • -I am able to open the device too

My question is: How do I list all files and directories in the pendrive?

From what I have read there are methods like

mDeviceConnection.controlTransfer(...)

that allow to read and write to the pendrive but how do I list the files and directories in the pendrive?

I want to be able to get absolute paths to files contained in the pendrive so I can transfer them to the sd card on the tablet.

Thanks

1 Answers1

0

Usually mounted pendrive are located in the folder /mnt/ so, you can retrieve all files and folder from that folder.

File storageDir = new File("/mnt/");
if(storageDir.isDirectory()){
    String[] dirList = storageDir.list();
    //TODO some type of selecton method?
}

It may happen that the folder is different for some devices, ex. /mnt/usb_storage/

StarsSky
  • 6,721
  • 6
  • 38
  • 63
  • 1
    When I connect the pendrive to the tablet I can now the path to the pendrive. I have a tosat that says `dev/usb/002/002/`. When I put this path on the code you gave it does not list me the files in that path. Do I have to be in root mode to get acces to the files via my app? Do I need some kind of configuration? – Isaac Costa Feb 04 '13 at 17:54