5

I am currently making an app that needs to be able to read from and write to a USB flash drive connected via a USB OTG adapter. Is there an easy way to access this storage via standard Java.io.File APIs? This app is only going to be run on a rooted Motorola Xoom running Android 4.2.2. Any suggestions would be appreciated.

Nathan Walters
  • 4,116
  • 4
  • 23
  • 37
  • Possible duplicate of [Android detect usb storage for kitkat (4.4)](http://stackoverflow.com/questions/36208297/android-detect-usb-storage-for-kitkat-4-4). There I posted solutions for pre-6.0 and 6.0/above. – Peter Tran Jun 16 '16 at 23:07

1 Answers1

5

USB Drives get mounted to your device just like an SDCard does essentially*.

The mount path usually resides at:

/storage/usb0/

I have not used this on many devices other then my Droid running CyanogenMod, your device may very. You can smiply use a file manager to explore this path. The directories will still exist even if there is no mount path, so you will be able to determine the path.

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • 1
    Thanks, this worked perfectly with a small modification. For future reference of anyone viewing this thread, the path for a Moto Xoom is `/storage/usbdisk0/`. – Nathan Walters Oct 26 '13 at 23:00
  • 6
    Is not there any method that returns its exact path on every device? – Bob Feb 04 '15 at 06:23