Krish
Krish

Reputation: 656

Phone is rooted but can't pull files from /data/data folder

My phone Samsung Galaxy S5 mini is rooted. I'm trying to pull files from /data/data/myapp.package/ to folder on my PC.

adb pull /data/data/myapp.package E:\myapp\myapp.package

it gives me this error

adb: error: failed to copy '/data/data/myapp.package' to 'E:\myapp\myapp.package': Permission denied

I found many questions like mine but no answer solved my problem. Some suggested to execute this command adb root before pulling files. Some suggested to install adbd insecure app to enable root access. In fact after installing that app, phone disappeared from adb terminal. Both solution didn't work for me.

BTW, I can copy files using cp command from adb shell but I have to copy files to sdcard and then pull from sdcard. I'm looking for solution which allows me to copy files directly from /data/data/myapp.package to my PC

Any solution?

Upvotes: 4

Views: 14165

Answers (4)

Here's a one-liner that lets you pull a file without installing anything else and without having to copy it to a public location on the device to then pull it to your computer:

adb shell su -c "cat /data/data/myapp.package/my_file.apk" > my_file.apk

What this does:

  • adb shell runs a command printing the raw binary output
  • su -c runs the provided command as root
  • cat <file> prints out the file contents
  • > <file> redirects the output from adb (i.e. the raw file contents) to a local file.

Upvotes: 3

Zarul Izham
Zarul Izham

Reputation: 591

This is my example pulling DB file from the root directory

adb -e shell "run-as com.example.project cp /data/data/com.example.project/databases/project.db /sdcard"

The key is run-as

Upvotes: 1

iVoid
iVoid

Reputation: 721

For your adb to be able to access /data/data directly (for adb pull), your adbd should be running as root - which can generally be done by adb root command.

adb root would not work on commercial devices like Samsung Galaxy S5 mini as commercial devices have ro.secure=1, i.e., the adbd can't be restarted as root due to a check of property called ro.secure. adbd insecure app circumvents this and restarts adbd in root mode to enable adb pull, etc. to work.

In short, if adbd insecure app doesn't work for you, it's not possible to do adb pull from /data/data in your existing ROM. It might be possible if you change the ROM / do some boot.img tweaks, but I would probably suggest trying latest version / different versions of adbd insecure app before going for ROM changes.

Read more on rooting here.

Upvotes: 7

Palak
Palak

Reputation: 2225

First you need to hit these two command from command line

adb root
adb remount

then

adb pull /data/data/myapp.package E:\myapp\myapp.package

Upvotes: 4

Related Questions