19

1. Added adb path to ~/.bash_profile

export PATH="/Users/myname/Library/Android/sdk/platform-tools:$PATH"

2. Logged in to emulator

adb -s emulator-5554 shell

3. changed permission of the app folder and parent folder

chmod 777 /data/data/com.me.myproject
chmod 777 /data/data

4. Still can not get stuff from outside. Why?

adb -s emulator-5554 pull /data/data/com.me.myproject

5 Answers 5

26

I had the same problem and I did this:

  1. adb shell
  2. run-as com.yourPackageName (not rooted device)
  3. cp 'database/file_you_want.db' '/sdcard/file_you_want.db'
  4. exit
  5. exit (now you will be back to main terminal window)
  6. adb pull /sdcard/xx.db
5
  • 4
    This only works if the app is in debug mode, not in release
    – Oush
    Dec 10, 2018 at 12:24
  • What should be xx.db ?
    – Vencovsky
    Jul 15, 2019 at 13:43
  • 1
    @Vencovsk name of our interested file, xx.db is just an example. Jul 16, 2019 at 6:05
  • 1
    so how to get that for release app?
    – gumuruh
    Nov 20, 2021 at 9:38
  • @gumuruh Not valid for release build app so far as i know. Maybe try on rooted device. Nov 21, 2021 at 7:19
17

That's because your debugging Android device is not rooted.

If you have a physical rooted device or have an emulated device, try executing this before, to restart ADB in root mode. Then any command should work:

adb root
0
2

The reason is the file you wanted to copy needs root permission. It's better to copy the file to /mnt/sdcard/ where you have a right to interact with.

  1. cp <file> /mnt/sdcard/
  2. adb pull /mnt/sdcard/<file>
2
  • cp ? where did i type that command? is it inside android studio or inside my mobilephone?
    – gumuruh
    Nov 20, 2021 at 9:37
  • @gumuruh you need to connect your android to your PC, and use those commands in the Terminal.
    – Ender
    Nov 24, 2021 at 15:06
0
  1. connect mobile to laptop then open adb console a). cp msg-store.db /mnt/sdcard/ ==>inside /data/data/packagename/databases/ b). adb pull /mnt/sdcard/msg-store.db/ ===>This will stored in local computer.
1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    May 20, 2022 at 13:03
-1

prefixing the remote path with ./ or removing the leading / makes the whole difference for me ??? I guess because the system folder must be relative to root's home?

Darn it, those stupid Linux folks wasted my time again. I admit my whole life is about relative paths but this one got me good. Make sure you use \ for your target file, stupid Bill G. also decided to go backwards with his slashes and that created a whole mess. :)

PS. What's even weirder both files in my examples were pulled (copied) to the BASH shell current folder NOT c:\ That's stupid or what :)

FAILS
adb -s 192.168.1.120:5555 pull /system/media/bootanimation.zip c:\boot1.zip
SUCCEEDS
adb -s 192.168.1.120:5555 pull ./system/media/bootanimation.zip c:\boot1.zip
SUCCEEDS
adb -s 192.168.1.120:5555 pull system/media/bootanimation.zip c:\boot1.zip

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.