8

I am trying to push a file to a directory on a physical android device, but I am running into the following error.

>adb push data.db /data/data/com.me.app/databases
failed to copy 'data.db' to '/data/data/com.me.app/databases/data.db': Permission denied

I believe adb has sufficient privileges.

>adb root
adbd is already running as root

Here are the permission details for the path: /data/data/com.me.app/databases

drwxrwxrwx system   system            2014-01-14 10:31 data
drwxrwxrwx system   system            2015-05-23 16:06 data
drwxrwxrwx u0_a224  u0_a224           2015-05-23 15:26 com.me.app
drwxrwxrwx u0_a224  u0_a224           2015-05-23 15:30 databases

I am not sure what to do here. Perhaps I am going about this the wrong way, but I just want to push the data.db file into the /data/data/com.me.app/databases directory on the device.

Does anyone know what I am doing wrong or what I should consider? Thanks.

1
  • 3
    Put your workaround as an answer here, and accept your own answer so people looking for a similar problem will see it answered when they search for it. May 24, 2015 at 4:05

3 Answers 3

6

Edit: I found a work-around: AirDroid allows me to upload the file, but the permissions on the file are set to this:

-rw-------

Performing the following commands solves this problem (from Windows 7 command prompt).

>adb shell
# su
# chmod 777 /data/data/com.me.app/databases/data.db
4

I had a variation of this problem so going to leave it here in case someone else googles for it:

./adb push update.zip /sdcard
[  0%] C:/Users/Alex/AppData/Local/Programs/Git/sdcard
adb: error: failed to copy 'update.zip' to 'C:/Users/Alex/AppData/Local/Programs/Git/sdcard':
remote secure_mkdirs failed: No such file or directory
update.zip: 0 files pushed. 41.6 MB/s (131072 bytes in 0.003s)

However in my case the problem was running adb from Git bash Shell (MinGW64). Running it from regular Windows shell worked fine.

4

The usual approach, which doesn't require any additional apps:

  1. Push to /data/tmp/;

  2. Copy on the device using adb shell, using cp if it's available on your device or cat if it isn't.

     > adb push data.db /data/tmp/data.db
     > adb shell
     # su # or run-as com.me.app
     # cp /data/tmp/data.db /data/data/com.me.app/databases/data.db
    

Remembering to change com.me.app to the correct package name for your app.

2
  • This approach worked for me. For completeness, I actually pushed an obb file to /sdcard/ and then used adb shell without root permissions to copy this file to the correct package folder for this file (in /sdcard/Android/obb/packagename/ where packagename needs to be changed to match that of your Android app. Jul 17, 2019 at 15:36
  • I had to create it first: adb shell mkdir /data/tmp/ ; adb shell chmod 777 /data/tmp/ ; adb push file /data/tmp/
    – elig
    Aug 15, 2020 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .