Search code examples
androidshelladblscp

No such file or directory when 'cp' but not with 'ls'


I am trying to copy the shared preferences folder of my app to the /sdcard partition from my PC using the following ADB command:

adb shell su -c "cp /data/data/com.anrapps.pixelbatterysaver/shared_prefs/ /sdcard/appdata/"

But this returns cp: Skipped dir '/data/data/com.anrapps.pixelbatterysaver/shared_prefs': No such file or directory. However when executing the ls command, it says that folder is present:

adb shell su -c "ls /data/data/com.anrapps.pixelbatterysaver"

cache code_cache files shared_prefs

What is the problem? May be permission related?


Solution

  • If you're trying to copy a whole directory, you need to use cp -r to make it a recursive copy.