Find the software path of an external USB drive?

I am new to android and I am planning projects.

I need to open or save some files on an external storage device (pendrive). How to find the external path of a storage device (pendrive).

+6
source share
4 answers

Someone else asked about this recently here .

Basically, the SDK only supports one “external storage”, and this is an SD card, not a “pen”.

+1
source

You will need an OTG cable and a built-in phone. Install the Stick holder from the play store. You can access pendrive

0
source

A USB device is recognized as a 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 the endpoints must satisfy the following:

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

For more information, see these links:

0
source

This gives you external storage:

 File root = Environment.getExternalStorageDirectory(); 


Get a public top-level external storage directory for hosting files of a certain type. This is where the user usually places and manages his files, so you have to be careful what you put here to make sure that you do not delete your files or interfere with their own organization.

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

-2
source

Source: https://habr.com/ru/post/918759/


All Articles