# Using adb To Copy Files To / From Your Android Device

Some devices, like the Galaxy Nexus and the HP Touchpad* (via the custom Android ROMs) don’t expose themselves as USB storage devices.  They instead use MTP or PTP to transfer media files (limiting to only photos and audio/video files being shown from the device).

This happens due to there being no separate sdcard on these devices, and ‘unplugging’ an sdcard from a running device to be exposed to the connected computer could cause running apps on the device itself to malfunction.  Android developer Dan Morill explains this here. He also mentions how the Nexus S doesn’t have this problem.

There are several apps that can open shares to the device using one of several protocols (DAV, SMB, etc.).  However, one quick way I’ve found to copy files to and from the device connected via USB to a computer is by using the adb tool.  It’s available as part of the ‘android-tools’ package on Fedora.

To copy a file from the computer to an android device connected via usb, use this:

adb push /path/to/local/file /mnt/sdcard/path/to/file

This will copy the local file to the device in the specified location.  Directories can be created on the device via the shell:

adb shell

and using the usual shell commands to navigate around and create directories.

* On the Touchpad, WebOS can expose the storage as a USB Storage Media.  The current nightly builds of CM9 can’t.

## 10 thoughts on “Using adb To Copy Files To / From Your Android Device”

1. JackLeEmmerdeur says:

Did not know that, although I’ve recently coded a bit with eclipse which, I guess, uses the adb-shell in the building process. I guess the shell has some advantages to root apps running on the device but, at least on windows (wonder if it’s available on linux), autocompletition of filenames, editing or viewing files with ‘vi’, ‘nano’ or ‘less’ isn’t build into the shell. So you have to copy the file to a local harddisc with ‘adb pull /sdcard/foo.txt D:\bar.txt’, edit it in Notepad++ and put it back on the device with ‘adb push D:\bar.txt /sdcard/’. I think I’ll write a gui for that. Will post the link if that’s ok?

1. Amit Shah says:

Of course! Feel free to share the link.

2. Nathaniel says:

if you have the android sdk for linux it will be in the files. Android-sdk.r22.3-linux.tgz from androids’ web sight you have it in your platform tools folder. ADB in shell is a linux terminal into it will remote shell right into the device if you wanted to pull somefile to local home or location where adb is its

adb push copies from location to device location.

now if you are like me you will just place adb with your other term commands and well done but if you do be mindful that you give exact file path or you will have to get it from where adb is.

2. Jose Ramon says:

Hi, I came to your post and found useful. Let me describe a problem I am having. My tablet does not load. I managed to recover apps via adb. However, I don’t manage to have access to sdcard: it seems to be empty. Idon’t think it is actually blank. Rather I feel the problem has to do with the issues you highlight. Can you think of any strategy to have access to my documents in sdcard. You mention several packages but I am not familiarized with the topic. Thanks

1. Amit Shah says:

You can try mounting the sdcard from the ‘adb shell’ and poking around.

3. Bsomkareshwar says:

I want to move a rom which i backed up and it is in sdcard/clockworkmod/restore

i want to move it to sdcard/clockworkmod/backup

my phone is LG L3 E400. rooted.