Copy folder from Android app to local Windows directory
Asked Answered
T

4

6

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?

Tindle answered 9/5, 2016 at 11:59 Comment(2)
try to look at this https://mcmap.net/q/1777882/-how-send-data-through-wifiFabe
There is a answer here https://mcmap.net/q/88605/-how-to-copy-selected-files-from-android-with-adb-pull that works for me.Cheri
U
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.

Unswear answered 9/5, 2016 at 12:6 Comment(0)
R
5

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.

Rechaba answered 4/10, 2019 at 10:41 Comment(1)
This should be marked as answer.. works on non-rooted phone as well ( worked with debug version of app though ). not with live appRadiotelegraph
E
1

This is my recommendation in 2024.

With Android Studio Giraffe | 2022.3.1 Patch 1, You may access the internal data directory in Device Manager.

Find the file you look for in /data/data/[your package name], then you can save it locally in your computer.

Screenshot of Android Studio Giraffe 2022.3.1 Patch 1

Ernaline answered 7/5, 2024 at 3:27 Comment(0)
U
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.

Unswear answered 9/5, 2016 at 12:6 Comment(0)
H
0

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

Homonym answered 9/5, 2016 at 12:47 Comment(5)
Here 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?Tindle
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.Unswear
Tried it on device again and it works. Perhaps it is because of Debug build?Tindle
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.Unswear
@Tindle yes, it's because of debug buildCollude

© 2022 - 2025 — McMap. All rights reserved.