Not able to access the database file through adb s

2019-06-14 02:13发布

问题:

I am trying to retrieve the database file from the phone. I am using the cmd and adb shell to do this. After access data/data when i do ls, it shows permission denied. I have phone my rooted. USB debugging is on. My CMD image is attached. Please guide where i am wrong. Thanks in advance

回答1:

To list all databases that you have:

adb shell run-as com.example.myapp ls /data/data/com.example.myapp/databases/

To download them, first, copy them to sdcard and then, pull it:

adb shell run-as com.example.myapp cp /data/data/com.example.myapp/databases/DATABASE_NAME /sdcard/

adb pull /sdcard/DATABASE_NAME

NOTE:

Remember to replace com.example.myapp by package name from your app.

Replace com.example.myapp by package marked in your AndroidManifest.xml

<manifest 
    package="com.example.myapp"/>
    ....
</manifest>