简体   繁体   English

如何使用USB电缆以编程方式将文件从PC复制到Android设备

[英]How to copy files from PC to Android Device programmatically using USB cable

I have an app that needs copy some files from PC to Android device programmatically through usb cable. 我有一个需要通过USB电缆以编程方式将某些文件从PC复制到Android设备的应用。 After the user connect an Android device in PC via usb cable and click on button "Copy files from PC to Device", I need to access directory "c:\\files_to_app" and copy all files inside that directory to an specific folder in sdcard or root directory Android device. 用户通过USB电缆在PC中连接Android设备并单击“将文件从PC复制到设备”后,我需要访问目录“ c:\\ files_to_app”并将该目录中的所有文件复制到sdcard中的特定文件夹或根目录Android设备。

How is the best approach to achieve it? 如何达到最佳效果?

Note. 注意。 I know that is possible using ctrl+c ctrl+v, but I really need automate the process. 我知道可以使用ctrl + c ctrl + v,但是我真的需要使过程自动化。

i think this will be useful.... To transfer file from pc to android device via USB Socket Communication is best approach. 我认为这将是有用的...。通过USB套接字通信将文件从PC传输到android设备是最好的方法。

You have to do some additional step of port forwarding on which the Socket Communication establish. 您必须执行建立套接字通信的端口转发的其他步骤。

Look at Tutorial https://github.com/user370305/Android-USB-Communication . 查看教程https://github.com/user370305/Android-USB-Communication

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM