0

Absolute path of storage connected via OTG in Android,

I have tried using storage access framework i can get the content uri of the directory selected but i couldn't convert to absolute file:// path.

https://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT_TREE

I need to store the absolute file path to scan the directories when the app is opened or when user access the folders.

As explained in SO How to get the file path from a device acting as a usb mass storage in android

this does provide the natively mounted otg storage devices, Samsung device natively mount the storage device where you can get the absolute path, but other device its not mounting natively,

I have tried out with String sdcard_path = System.getenv("SECONDARY_STORAGE"); it won't provide the usb mounted path.

Environment.getExternalStorageDirectory() provides the internal mounted device path /storage/emulated/0/ /sdcard/

not the otg mounted storages.

OK200
  • 727
  • 6
  • 22
  • 1
    Possible duplicate of [How to get the file path from a device acting as a usb mass storage in android](https://stackoverflow.com/questions/30297714/how-to-get-the-file-path-from-a-device-acting-as-a-usb-mass-storage-in-android) – Dr Mido Mar 12 '19 at 04:19
  • @DrMido i have tried using Environment.getExternalStorageDirectory() this provides the internal storage of the device, not the otg mounted storage – OK200 Mar 12 '19 at 04:29
  • Did you read the whole answer? he said "But mount points in Unix are seen at the root level. Therefore, try directly /mnt/usb_storage/Garmin/system.xml, instead." – Dr Mido Mar 12 '19 at 04:34
  • @DrMido, how can i get Gramin in /mnt/usb_storage/Garmin, can you please help me in that – OK200 Mar 12 '19 at 04:43
  • check this to get all storage drives https://stackoverflow.com/a/51283579/9821661 – milan pithadia Mar 12 '19 at 05:45

0 Answers0