5

I'm trying to use the Android Adb Command Prompt to copy a folder inside the app container to a local Windows folder. The device is running Android 5.1.1 and is not rooted.

adb pull or cp aren't working. How can I copy a folder?

The following approaches aren't working:

Approach 1

adb shell
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test

error: device not found

Inside the shell you can't see to do adb pull. See here.

Approach 2

DDMS can't access the data folder.

Approach 3

adb shell
run-as DroidSample.DroidSample
cp /files/MetroLog/MetroLogs/ C:/temp/test

cp: /files/MetroLog/MetroLogs/: No such file or directory

Approach 4

adb shell
run-as DroidSample.DroidSample
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs/ C:/temp/test

cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs is a directory (not copied).

This is also not working.

Approach 5

adb shell
run-as DroidSample.DroidSample
chmod 777 /files/MetroLog/MetroLogs
exit
exit
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
adb shell run-as DroidSample.DroidSample
chmod 700 /files/MetroLog/Metrologs

remote object '/data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs' does not exist

So also this isn't working.

Approach 6

adb shell
mkdir /sdcard/tmp
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs /sdcard/tmp

cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs: Permission denied

This is also not working.

Approach 7

The only thing which half work is this

adb exec-out run-as DroidSample.DroidSample cat "files/MetroLog/MetroLogs/Log - 20160509.log" > C:/temp/test/test.log

But here I don't get the original file and I also have to know the exact file name. Additionally, that I loose line breaks and I have to do this for each file. Not that what I want.

So I'm running out of ideas. How can I access the internal stored files and copy them over?

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417

3 Answers3

3

You have almost solved the problem. As the storage of this kind is secured, you need to do one additional step. You need to copy the file from secured location to sdcard of the device. And then you can copy it anywhere via usb or android pull. Here are the command sequence I executed successfully.

adb shell
run-as DroidSample.DroidSample
cd shared_prefs
cp  DroidSample.DroidSample_preferences.xml /sdcard/DroidSample.DroidSample_preferences.xml
exit
exit
adb pull /sdcard/DroidSample.DroidSample_preferences.xml C:/test/

That's it.

And I really appreciate the way you posted your question. Best of luck.

Neo
  • 3,546
  • 1
  • 24
  • 31
  • 2
    This should be marked as answer.. works on non-rooted phone as well ( worked with debug version of app though ). not with live app – Amod Gokhale Dec 05 '20 at 12:55
0

You're trying to gain read access to /data partition on actual android device. Such thing is not possible without root access, even if the app folder is yours. For the reason that permissions to read /data partition are not granted and cannot be granted, unless you're using an emulator. On emulator, which by default is with admin privileges for developer, you can access the data partition to read and write. On actual device you cannot. Not with adb, not with DDMS.

So basically speaking, anything that requires access to those files under /data is not going to work. Whether you sue cp command or pull command. The moment your kernel reads the beginning of your path which starts with /data/... it says: Oops, no can do.

daxgirl
  • 762
  • 4
  • 10
0

You are trying to access /data folder of android device which is not accessible in unrooted device.

Mehta
  • 1,228
  • 1
  • 9
  • 27
  • 1
    [Here](http://stackoverflow.com/questions/18471780/android-adb-retrieve-database-using-run-as) the question was explicitely of accessing files from `data` folder for **unrooted** devices. I was able to access a file from `data` folder with `adb exec-out run-as com.packagename cat source > destination`. Why does this work then? – testing May 09 '16 at 13:55
  • It works on emulator. Not on actual device. It could never ever work on actual device. Neither you nor adb has read permissions for /data partition. View my answer. – daxgirl May 09 '16 at 15:07
  • Tried it on device again and it works. Perhaps it is because of Debug build? – testing May 09 '16 at 15:20
  • May very well be but I doubt it. As of your original question, none of the methods you listed will work. No access to data partition can be granted to you. – daxgirl May 09 '16 at 15:27
  • @testing yes, it's because of debug build – Pavlus Sep 28 '17 at 08:57