jhnclvr
jhnclvr

Reputation: 9487

Android adb push to location in device with no sdcard and no root access

Is there any location on an android device that we can push a file (using adb) if the device has no SD card and we do not have root access?

(I am trying to push a properties file onto the device, so I will also need to be able to read from this location inside an activity running on the device)

Upvotes: 12

Views: 13550

Answers (3)

reinra
reinra

Reputation: 101

ADB push seems to work fine with '/data/local/tmp'.

Upvotes: 7

JesusFreke
JesusFreke

Reputation: 20282

/data/local is typically readable and writeable by the shell user (the user that adb shell runs under). So you should be able to adb push a file to /data/local.

In order for an application to be able to access it, you'll also have to set the permissions on the file appropriately

adb push prefs.txt /data/local
adb shell chmod 664 /data/local/prefs.txt

Another approach would be to have your application create a new directory under it's application data directory on the device and set the permissions on the directory to be world readable/writeable, which should allow you to adb push to there.

Upvotes: 6

JD.
JD.

Reputation: 3035

Every device has the capacity to be different. On some phones, such as the Samsung Galaxy S Vibrant, the /sdcard/ mount is writeable by any host connected through adb. On others, such as the MyTouch 4G, 'adb push' cannot send any files to any destination at all.

If you are testing with just one or two devices, open an adb shell and issue commands such as df and ls -l to see what mount points there are, and the file permissions, respectively.

If your user can execute find on the Android device, that's a real boon and you can probably use that to locate files writeable by the current effective uid (or writeable by all).

Some directories to try:


    /sdcard
    /data
    /tmp
    /opt

You've probably already seen the adb page but I'm linking it just in case.

Example df output:


    $ df 
    /dev: 318068K total, 64K used, 318004K available (block size 4096)
    /system: 558668K total, 468920K used, 89748K available (block size 4096)
    /data: 1190256K total, 129868K used, 1060388K available (block size 4096)
    /cache: 294628K total, 16720K used, 277908K available (block size 4096)
    /devlog: 21100K total, 6056K used, 15044K available (block size 4096)
    /mnt/asec: 318068K total, 0K used, 318068K available (block size 4096)
    /mnt/obb: 318068K total, 0K used, 318068K available (block size 4096)
    /app-cache: 8192K total, 0K used, 8192K available (block size 4096)

Upvotes: 7

Related Questions