176

How to push a file from computer to an Android device having no SD Card in it. I tried:

C:\anand>adb push anand.jpg /data/local
3399 KB/s (111387 bytes in 0.032s)

C:\anand>adb push anand.jpg /data/opt
3199 KB/s (111387 bytes in 0.034s)

C:\anand>adb push anand.jpg /data/tmp
3884 KB/s (111387 bytes in 0.028s)

Above commands to move a file anand.jpg to a device but I didn't get this jpg file in the device. I didn't get any success result on cmd prompt, I only got:

3399 KB/s (111387 bytes in 0.032s).
6
  • 4
    Try adb shell "cd /data/local && mkdir tmp" then adb push anand.jpg /data/local/tmp. How do you check for the file on the device, with adb shell?
    – user180100
    Commented Dec 30, 2013 at 6:15
  • 1
    @RC i am using ls command to check the files. i got it atleast on the DDMS view on emulator.but still i didnt get it on the device. when i am trying "adb push" command it shows device not found for real device. but adb devices is showing the device. Commented Dec 30, 2013 at 11:41
  • I would stop the emulator, unplug the device, then after ensuring device is in debug mode, plug the device and retry
    – user180100
    Commented Dec 30, 2013 at 12:10
  • 1
    This question appears to be off-topic because it is not about programming. See What topics can I ask about here in the Help Center. Perhaps Android Enthusiasts Stack Exchange would be a better place to ask.
    – jww
    Commented Oct 14, 2014 at 21:11
  • 1
    RC's suggestion worked in this variation for me: adb shell "cd /sdcard && mkdir temp" then abd push x.apk /sdcard/temp" I ended up with my file in the temp folder on my sdcard, and was able to flash from there. Commented Feb 26, 2015 at 13:18

19 Answers 19

223

From Ubuntu/Mac Terminal, the below command should work.

./adb push '/home/hardik.trivedi/Downloads/one.jpg' '/data/local/'

For adb v33 and above if you are getting a permission denied error, try what I tried. The following command and it works fine. The only caveat is you might need to use tmp directory on such an emulator.

adb shell #Entering into shell
su #Super user mode
chmod 777 /data/local/tmp/ #Granting RWX access
exit
chmod 777 /data/local/tmp/ #Granting RWX access
exit

And then try

./adb push '/home/hardik.trivedi/Downloads/one.jpg' '/data/local/tmp/'
13
  • 3
    Can we do this without rooting the phone?
    – Jacob
    Commented Jan 10, 2015 at 20:54
  • 2
    @HardikTrivedi: Are you saying that rooting is needed to use adb push in general, or for this particular file destination? I'm using adb push to write a file on the Android device's SD card on a non-rooted device.
    – RenniePet
    Commented Feb 24, 2015 at 23:56
  • 3
    To push command works for non rooted phone also, only /data folder is requires rooted user. Commented Feb 25, 2015 at 4:44
  • 1
    For adb v33 and a Google store image this no longer works. Commented Dec 13, 2022 at 14:18
  • 1
    @SimonFeatherstone Hey bud!, I have updated my answer. I hope it works for you. Thanks for reporting :) Commented Dec 13, 2022 at 17:26
62

I did it using the push command, which has syntax:

adb push filename.extension /sdcard/0/

Example of copying directory, and sub-directory content:

adb push C:\my-location\data\. /storage/emulated/0/Android/data

Note that push did just hang in latest platform-tools (33.0.1, at time of writing) for a certain amount of files, beside the adb.exe suddenly taking 5MB+ instead of 1.5MB, hence I just did replace the adb.exe with one I had from 28.0.0 version of platform-tools (I did not downgrade the entire platform-tools, because adb.exe is kind of stand-alone).

I don't say there is any conspiracy around data folder,

But my Samsung device puts limits on my USB file transfer, beside Android v11+ not allowing access to data folder anymore, hence I needed above command to work with 100% speed (without hanging one hour for little more files).

1
  • 3
    just moved an mp3 file from mac osX to an android 5.0 device and I had to write the name of the file to be on the device, i.e. "adb push /file.mp3 /sdcard/fileOrOtherFileName.mp3 " Commented Nov 18, 2015 at 13:25
37

Follow these steps :

go to Android Sdk then 'platform-tools' path on your Terminal or Console

(on mac, default path is : /Users/USERNAME/Library/Android/sdk/platform-tools)

To check the SDCards(External and Internal) installed on your device fire these commands :

    1. ./adb shell (hit return/enter)
    1. cd -(hit return/enter)

now you will see the list of Directories and files from your android device there you may find /sdcard as well as /storage

    1. cd /storage (hit return/enter)
    1. ls (hit return/enter)

you may see sdcard0 (generally sdcard0 is internal storage) and sdcard1 (if External SDCard is present)

    1. exit (hit return/enter) (to come out of adb shell)
    1. ./adb push '/Users/SML/Documents/filename.zip' /storage/sdcard0/path_to_store/ (hit return/enter) (to copy file)
15

After Trying all the answers this worked for me

Where I am Pushing a file on Desktop to Android Device (Redmi K20 pro) connected Over the air using adb.

This command pushes the file to the downloads folder on my phone

adb push ~/Desktop/notifications.drawio ./storage/emulated/0/Download

after running this if you get a permission denied error

try running these commands in order (which basically changes the directory permission)

adb shell

chmod 777 /data/local/tmp

exit

and then run try the adb push command

I have documented this here feel free to share your views and help improve it.

13

run below command firstly

adb root
adb remount

Then execute what you input previously

C:\anand>adb push anand.jpg /data/local
C:\anand>adb push anand.jpg /data/opt
C:\anand>adb push anand.jpg /data/tmp
0
12

Try this to push in Internal storage.

adb push my-file.apk ./storage/emulated/0/

Works in One plus device, without SD card.

1
11

Sometimes you need the extension,

adb push file.zip /sdcard/file.zip

1
  • 1
    I have LG Nexus 5 and you can't put external sdcard in it but a part of the internal memory behaves like it was an sdcard In this case sdcard is just a directory at the root level You can check it with calling 'adb shell' When you are in the shell call 'ls' for directory listing
    – cstuncsik
    Commented Jul 8, 2016 at 19:05
5

My solution (example with a random mp4 video file):

  1. Set a file to device:

    adb push /home/myuser/myVideoFile.mp4 /storage/emulated/legacy/
    
  2. Get a file from device:

    adb pull /storage/emulated/legacy/myVideoFile.mp4 
    

For retrieve the path in the code:

String myFilePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myVideoFile.mp4";

This is all. This solution doesn't give permission problems and it works fine.

Last point: I wanted to change the video metadata information. If you want to write into your device you should change the permission in the AndroidManifest.xml. Add this line:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
4

I've got a Nexus 4, that is without external storage. However Android thinks to have one because it mount a separated partition called "storage", mounted in "/storage/emulated/legacy", so try pushing there: adb push anand.jpg /storage/emulated/legacy

1
  • For my nexus 4 /sdcard.file.zip worked like a charm.
    – sud007
    Commented Dec 15, 2015 at 6:42
4

As there are different paths for different versions. Here is a generic solution:

Find the path...

  1. Enter adb shell in command line.
  2. Then ls and Enter.

Now you'll see the files and directories of Android device. Now with combination of ls and cd dirName find the path to the Internal or External storage.

In the root directory, the directories names will be like mnt, sdcard, emulator0, etc

Example: adb push file.txt mnt/sdcard/myDir/Projects/

2

In Mac: To push files via adb

adb push /Users/Downloads⁩/amazon.sdktester.json '/mnt/sdcard/amazon.sdktester.json'
1

This might be the best answer you'll may read. Setup Android Studio Then just go to view & Open Device Explorer. Right-click on the folder & just upload a file.

1

To push all the files at your directory to the Android device use:

PS D:\myFiles> adb push . '/data/local/tmp/'
1

Accoding to Android Developers, the following command is suggested.

adb push myfile.txt /sdcard/myfile.txt

Using /sdcard as the remote path also worked in Redmi Note 10 Pro.


If the adb push fails, try switching remote to one of the following paths.

/data/local
/data/local/tmp
/data/opt
/data/tmp
/mnt/sdcard
/sdcard
/sdcard/0
/storage/emulated/0
/storage/sdcard0
0

You are trying to write to system folders. With ADB you have root (admin) access so you see the system folders of which sdcard is one of them so to send a picture you could use

D:\Program Files\Android\sdk\platform-tools\adb push am files\android sdk\adb.exe push C:\Downloads\anand.jpg /sdcard/pictures/

NB: C:\Downloads\anand.jpg replace with path and name to picture..

0

Certain versions of android do not fire proper tasks for updating the state of file system. You could trigger an explicit intent for updating the status of the file system. (I just tested after being in the same OP's situation)

adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///

(You could pass a specific filepath instead of file:/// like file:///sdcard )

1
  • I'd like to add specify something. I've been using this command for a while now but in a bit different format. adb -s $device shell am broadcast -W android.intent.action.MEDIA_SEARCH. The -s $device is needed if you have more than one attached device. Commented Aug 22, 2021 at 8:59
0

In my case, I had an already removed SDCard still registered in Android. So I longpressed the entry for my old SDCard under:

Settings | Storage & USB

and selected "Forget".

Afterwards a normal

adb push myfile.zip /sdcard/

worked fine.

0

I'm using Galaxy S22u with Android 14, and if it matters, OneUI 6.0, and this series of Galaxy has no slot for an SD card, however, adb shows my device has /sdcard/... storage, where /sdcard is a link: sdcard -> /storage/self/primary.

In other words, I can "adb push file.xyz /sdcard/Zyx" where Zyx is a directory on my S22u, in reality, it's a directory at /storage/self/primary/Zyx.

0

To correctly use adb push command we need to first understand about the parameters and when to use forward slash and the backslash. Local system path should use backslash ( \ ) and anything which goes to the Android device should use forward slash ( / ).

For example, if we have to copy an APK file from the local system to the Android device:

adb push <source> <destination>

adb push C:\Desktop\Sample.apk /sdcard/Download/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.