How to programmatically copy files from internal storage to external Usb Mass storage device

How to programmatically copy files from internal storage to an external Usb Mass Storage Device connected via OTG. It is clear how to get the device through UsbManager and determine that it is a Mass Storage Device, but how to then get through to its file system is not clear. I read that this is possible using the Storage Access Framework, but I did not find any similar examples.

Author: Kirill21, 2018-06-13

1 answers

First, we get a list of root folders:

File roots[]=File.listRoots();

Next, in the loop, we check whether the root is physically disconnected or not:

Environment.isExternalStorageRemovable(File );

If it is detachable, it is a flash drive.

 2
Author: Barmaley, 2018-06-14 08:48:25