Joop
Joop

Reputation: 3788

How to write files to your desktop with the use of an android application using an emulator or USB-connected device using for example Android Studio?

I wrote some classes for my Android-program and it runs. However it takes too much ram because the data in the File is not in a nice form to be processed by the application. Let's call the File Foo.txt for now.

I now want to save the data from Foo.txt in a different form which lets my Android specific code (specific in the sense that it uses Activities, Context etc) do easily since I have all the code for it already, and then load from this data manipulatedFooFile.txt instead. Problem is, I don't know if it's possible at all to save to a file which I can then later retrieve on the desktop, either in an emulator or via a device connected to an USB or a way I don't know of yet. This way I can replace Foo.txt with manipulatedFooFile.txt which would let me use less ram and space on disk.

I know that one other solution would be to remove the code from android and put it into a normal java program. Put that would take a bit of struggle since I have to remove all the dependencies on code that is not there, or start with nothing and write big parts of the code again.

Upvotes: 0

Views: 885

Answers (1)

initramfs
initramfs

Reputation: 8405

Files and folders can be sent to and from your android device using adb (or android debug bridge).

Using the adb pull command under the syntax adb pull <remote> <local> you are able to transfer a file from the filesystem of the connected android device to your local device (your computer).

From the official documentation for adb pull:

Copies a specified file from an emulator/device instance to your development computer.

Similarly, adb push allows you to push a file from your local computer to the target emulator/android device under the syntax adb push <local> <remote>.

Upvotes: 1

Related Questions