How can one pull the (private) data of one's o

2019-01-10 00:10发布

Attempting to pull a single file using

adb pull /data/data/com.corp.appName/files/myFile.txt myFile.txt

fails with

failed to copy '/data/data/com.corp.appName/files/myFile.txt myFile.txt' to 'myFile.txt': Permission denied

despite that USB debugging is enabled on the device.

We can go around the problem through the archaic route

adb shell
run-as com.corp.appName
cat files/myFile.txt > myFile.txt

but this is unwieldy for more than one file.

How can I pull the directory /data/data/com.corp.appName/files to my MacBook?

Doing this either directly or through a transit in `/storage/sdcard0/myDir (from where I can continue with Android File Transfer) is fine.

Additional Comment

It may be that just running

adb backup  -f myFiles com.corp.appName

will generate the files I am looking for. In that case I am looking for a way to untar/unzip the resulting backup!

标签: android adb
14条回答
够拽才男人
2楼-- · 2019-01-10 00:17

you can do:

adb pull /storage/emulated/0/Android/data//

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-10 00:23

Here is what worked for me:

adb -d shell "run-as com.example.test cat /data/data/com.example.test/databases/data.db" > data.db

I'm printing the database directly into local file.

查看更多
冷血范
4楼-- · 2019-01-10 00:23

If you are using a Mac machine and a Samsung phone, this is what you have to do (since run-as doesn't work on Samsung and zlib doesn't work on Mac)

  1. Take a backup of your app's data directory adb backup -f /Users/username/Desktop/data.ab com.example

  2. You will be asked for a password to encrypt in your Phone, don't enter any. Just tap on "Back up my data". See How to take BackUp?

  3. Once successfully backed up, you will see data.ab file in your Desktop. Now we need to convert this to tar format.

  4. Use Android Backup Extractor for this. Download | SourceCode

  5. Download it and you will see abe.jar file. Add this to your PATH variable.

  6. Execute this to generate the tar file: java -jar abe.jar unpack /Users/username/Desktop/data.ab /Users/username/Desktop/data.tar

  7. Extract the data.tar file to access all the files

查看更多
再贱就再见
5楼-- · 2019-01-10 00:25

I had the same problem but solved it running following:

$ adb shell
$ run-as {app-package-name}
$ cd /data/data/{app-package-name}
$ chmod 777 {file}
$ cp {file} /mnt/sdcard/

After this you can run

$ adb pull /mnt/sdcard/{file}
查看更多
可以哭但决不认输i
6楼-- · 2019-01-10 00:27

Similar to Tamas's answer, here is a one-liner for Mac OS X to fetch all of the files for app with your.app.id from your device and save them to (in this case) ~/Desktop/your.app.id:

(
    id=your.app.id &&
    dest=~/Desktop &&
    adb shell "run-as $id cp -r /data/data/$id /sdcard" &&
    adb -d pull "/sdcard/$id" "$dest" &&
    if [ -n "$id" ]; then adb shell "rm -rf /sdcard/$id"; fi
)
  • Exclude the -d to pull from emulator
  • Doesn't stomp your session variables
  • You can paste the whole block into Terminal.app (or remove newlines if desired)
查看更多
我只想做你的唯一
7楼-- · 2019-01-10 00:27

Backed up Game data with apk. Nougat Oneplus 2.

**adb backup "-apk com.nekki.shadowfight" -f "c:\myapk\samsung2.ab"**
查看更多
登录 后发表回答