将文件从android复制到USB驱动器?

将文件从android复制到USB驱动器?,android,io,usb,Android,Io,Usb,无法找到将文件从android设备复制到USB驱动器的好解决方案。我知道android从3.1版开始就有了API。但是文档不是很清楚,我可以在哪里使用这些API。有没有人在这方面有经验?我注册了广播接收器,在允许usb连接到应用程序后,只想将一些字节传输到usb存储,如下所示: Set<String> devices = mUsbManager.getDeviceList().keySet(); Object[] array = devices.toArray()

无法找到将文件从android设备复制到USB驱动器的好解决方案。我知道android从3.1版开始就有了API。但是文档不是很清楚,我可以在哪里使用这些API。有没有人在这方面有经验?我注册了广播接收器,在允许usb连接到应用程序后,只想将一些字节传输到usb存储,如下所示:

     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);
Set devices=mUsbManager.getDeviceList().keySet();
Object[]数组=devices.toArray();
字符串文本=数组[0]。toString();
byte[]s=“你好”。getBytes();
usbdeviconnection connection=mUsbManager.openDevice(mUsbManager.getDeviceList().get(text));
UsbEndpoint UsbEndpoint=mUsbManager.getDeviceList().get(text).getInterface(0).getEndpoint(0);
连接.散装运输(美国本德点,s,s.长度,10000);
然而,我并没有得到我所期望的。有人能帮忙吗?
提前感谢

在此链接上找到了解决方案:。您需要编写文件系统以与usb驱动器交互