title: How can I read files from usb device on android?
body: <p>I'm trying to create something like file explorer through connected usb devices(via OTG or usb ports on android TV). 
  All I need for this is a path something like "/storage/sda4" and device identifier, and then I can work with device through simle android class File. Is sounds simple but I can't find any info about this, but all file explorers can do it (for example ESExplorer).
  Ok, I find a simple way to get all connected usb devices with identifier </p>
  
  <pre><code>UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
  usbManager.getDeviceList();
  </code></pre>
  
  <p>but how can I get an info about path? deviceName contains something like this "/dev/bus/usb/00x" but it can't help me, I need simple emulated android path ("/storage/sda4"). This page <a href="https://developer.android.com/guide/topics/connectivity/usb/host.html" rel="noreferrer">https://developer.android.com/guide/topics/connectivity/usb/host.html</a> tells that I need to get UsbInterfaces and make UsbConnection to bulk transfer and other bullshit, I done it all but didn't find path to device or any other info about usb file list.</p>
  
  <p>Ok, I find another way to get (that don't requires permission!) to get path to all connected devices</p>
  
  <pre><code>StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
  Method getVolumeListMethod = StorageManager.class.getDeclaredMethod("getVolumeList");
  Object[] storageVolumeList = (Object[]) getVolumeListMethod.invoke(storageManager);
  </code></pre>
  
  <p>and it works but I need to identify a device(because I want to cache files of different usb storages) but all that I can get from volume object is mStorageId, mDescriptionId, mPrimary, mRemovable, mEmulated, mMtpReserveSpace, mAllowMassStorage, mMaxFileSize, mOwner, mUuid, mUserLabel, mState, mSubSystem.
  None of this can not identify the device: mDescriptionId and mStorageId are
  unique fot usb port, mUuid is null, mUserLabel is not unique.</p>
  
  <p>Environment.getExternalFilesDirs() won't help, it don't provide any device id and works only with one device.</p>
  
  <p>I find a similar question here, but it has no right answer <a href="https://stackoverflow.com/questions/34795622/android-list-files-from-usb-drive">Android list files from USB Drive</a>.</p>
  
  <p>Well, is a simple way to get list of usb devices with path and identifier exists?</p>