7

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 ).

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
Sekar
  • 1,061
  • 7
  • 21
  • 38
  • Have you try this `String url = Environment.getExternalStorageDirectory();` ? – Viktor Apoyan Jun 22 '12 at 13:09
  • Check this [link](http://stackoverflow.com/questions/5694933/find-an-external-sd-card-location) – Viktor Apoyan Jun 22 '12 at 13:11
  • Although the original title was bad, this is a question about USB storage devices, not the android ExternalStorage (sdcard or soldered-in flash) – Chris Stratton Jun 23 '12 at 14:01
  • @Chris I aggree this question title. But my problem is, I am using one android tablet and then i connected to the one external USB storage device ( Pendrive ). How to find out this external USB storage device path. Because i need to access some files from Pendrive. Sorry for bad english. Thanks for your idea.. – Sekar Jun 25 '12 at 05:09

4 Answers4

1

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".

Community
  • 1
  • 1
Barak
  • 16,318
  • 9
  • 52
  • 84
  • Yup. Also, to my knowledge, no devices support USB storage devices out of the box. You can flash custom kernels which enable it on 4.0 devices, but as of yet I don't know of any devices which officially support it. – Kevin Coppock Jun 22 '12 at 13:50
1

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:

Community
  • 1
  • 1
A_rmas
  • 784
  • 2
  • 10
  • 26
-2

You will need an OTG cable and a rooted phone. Install Stick mount from play store. You can access pendrive

cprog
  • 7
  • 6
-3

This does give you the external Storage:

File root = Environment.getExternalStorageDirectory();


Get a top-level public external storage directory for placing files of a particular type. This is where the user will typically place and manage their own files, so you should be careful about what you put here to ensure you don't erase their files or get in the way of their own organization.

See docs: http://developer.android.com/reference/android/os/Environment.html#getExternalStoragePublicDirectory(java.lang.String)

Thkru
  • 4,218
  • 2
  • 18
  • 37
  • 4
    Not relevant. The original title was bad, but this is a question about USB storage devices, not the android ExternalStorage (sdcard or soldered-in flash) – Chris Stratton Jun 23 '12 at 14:01