Copy Files from Android devices

Copying files from /data on non-rooted Android device

I was trying to retrieve a sqlite Database from an application that was running on a non-rooted device. This usually is not possible from outside the app without root access.
Found this blog entry that solved my problem.

You need to have the android SDK on the PC and “USB debug” enabled on the device. After that on a shell/command prompt you can do:

c:\>adb -d shell
shell@android:/ run-as _the_package_name_of_the_app_
shell@android:/data/data/_the_package_name_of_the_app_$ cat databases/_DB_NAME > /sdcard/_DB_NAME

Of course, you need to change _the_package_name_of_the_app_ and _DB_NAME for the appropriate values for your application.
This will copy the database to the SD card that can then be accessed normally from the PC.

There is also a programmatic way, where the user can instruct this copy. Of course this requires changing the app. See this example (go to the bottom for the code to copy).