Since I'm as dumb as you are, I would go the way of using the ls .
Code example:
try { Process process = Runtime.getRuntime().exec("ls /storage/UsbDriveA"); BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); String listOfFiles = ""; String line; while ((line = buffer.readLine()) != null) { listOfFiles += line; } } catch (InterruptedException e) { e.printStackTrace(); }
ls will return no such file or directory if the mount point is incorrect.
Here is a list of many mount point manufacturers:
/storage/UsbDriveA (all Samsung devices) /storage/USBstorage1 (LG G4, V10, G3, G2, other LG devices) /storage/usbdisk (Moto Maxx, Turbo 2, Moto X Pure, other Motorola devices) /storage/usbotg (Sony Xperia devices, Lenovo Tabs) /storage/UDiskA (Oppo devices) /storage/usb-storage (Acer Iconia Tabs) /storage/usbcard (Dell Venue -- Vanilla Android 4.3 tablet) /storage/usb (HTC One M7, and some Vanilla Android devices)
(Based on my collection of devices and 3 other people and a quick trip to Bestbuy for testing the latest flagships. The only popular devices that I know I miss are Hawuei / Xioami devices based in China, which are becoming popular in English countries, but they probably use one of the above.)
To find the mount point you need, you must listen to no such file or directory and loop / re-execute the exec() statement with the next mount point.
Once all this is done, you can easily read the files using cat /storage/.../file.txt and write using redirection: echo test > /storage/.../file.txt
Hope this helps
source share