Save file from android device to windows programmatically

倾然丶 夕夏残阳落幕 提交于 2020-01-05 07:56:29

问题


Is there any way to save a text file created from an android app to a USB connected windows PC programmatically?


回答1:


No, sorry. Android devices have no access to their host PC via USB cable.




回答2:


Short answer - not that I know of.

For "file transfer" in general, I would definitely look at both Dropbox (save/synch anything to anything, anywhere) and ESFileExplorer. Both are user-oriented, but Dropbox has an API that you should be able to use with Android (I haven't tried it). ESFileExplorer works with both USB and Windows shares.

If you have the Android SDK, you can copy files from the command line with "adb pull". And of course you can invoke "adb pull" from Java with "Runtime.exec()". Ugly ... but do-able :)

One other possibility for Windows shares might be:

a) Get an SMB client (for example, Samba Filesharing), then

b) Use standard Java IO to read and write to and from the share

Again, I haven't tried this ... and I don't know if it would work ... but it might be worth a shot. I don't see anything in Android File I/O that appears fundamentally incompatible with Samba file sharing:

  • http://developer.android.com/reference/java/io/File.html



回答3:


Try using adb pull command from your PC to fetch the file from Android. You will need to install the Android SDK and have a usb cable (although there are ways to do it wirelessly).




回答4:


You cannot write a file from an Android device to a PC by Android programming. However, you can copy a file from Android device by Windows programming (C#). You can get help from windows device portable library: https://github.com/notpod/wpd-lib



来源:https://stackoverflow.com/questions/12608893/save-file-from-android-device-to-windows-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!