support_ms
support_ms

Reputation: 1933

Copy files from android to USB drive?

Can not find good solution of how to copy files from android device to USB drive. I know that android has API's for that since 3.1 version. However docs are not very clear, where I can use that APIs. Is there someone who has experience on this area? I registered broadcast receiver and after allowing usb connection to app, just wanted to transfer some bytes to USB storage like below:

     Set<String> devices = mUsbManager.getDeviceList().keySet();
     Object[] array = devices.toArray();
     String text = array[0].toString();
     byte [] s="hello".getBytes();
     UsbDeviceConnection connection=mUsbManager.openDevice(mUsbManager.getDeviceList().get(text));
 UsbEndpoint usbEndpoint=mUsbManager.getDeviceList().get(text).getInterface(0).getEndpoint(0);
connection.bulkTransfer(usbEndpoint,s,s.length,10000);

However, I did not get what I expect. Could someone help, please? Thanks in advance

Upvotes: 2

Views: 2973

Answers (1)

support_ms
support_ms

Reputation: 1933

Found solution on this link: https://github.com/mjdev/libaums. You need to write your file system to interact with the usb drive

Upvotes: 3

Related Questions