kosbou
kosbou

Reputation: 3999

Save file from android device to windows programmatically

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

Upvotes: 1

Views: 3813

Answers (4)

paulsm4
paulsm4

Reputation: 121869

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:

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

  2. 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

Upvotes: 1

Ali Kharazani
Ali Kharazani

Reputation: 11

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

Upvotes: 0

vokuheila
vokuheila

Reputation: 185

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).

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007544

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

Upvotes: 2

Related Questions