Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find external USB storage device path programmatically?

Tags:

android

I am new to android and I am doing some project planning.

I need to access / store some files to External storage device ( pendrive ). How to find external storage device path ( pendrive ).

like image 246
Sekar Avatar asked Jun 22 '12 13:06

Sekar


Video Answer


2 Answers

Someone else asked this recently here.

Basically, the SDK has support for only one "external storage", and that is an SD card, not a "pen drive".

like image 137
Barak Avatar answered Sep 20 '22 12:09

Barak


USB device is recognized as Mass Storage device if:

usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE
             || usbInterface.getInterfaceSubclass() == INTERFACE_SUBCLASS // int 6
             || usbInterface.getInterfaceProtocol() == INTERFACE_PROTOCOL // int 80

and

usbInterface.getEndpointCount() == 2

where one of endpoint must satisfy following:

endPoint direction == 0
endPoint type = UsbConstants.USB_ENDPOINT_XFER_BULK //int 2

Refer these links for further details:

  • Usb detect storage device

  • Usb device interface not found

like image 36
A_rmas Avatar answered Sep 18 '22 12:09

A_rmas