0

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

enter image description here

Mudasir Sharif
  • 733
  • 2
  • 15
  • 31

1 Answers1

3

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>
guipivoto
  • 18,327
  • 9
  • 60
  • 75
  • Still it shows that com.example.mudasir.login is unknown – Mudasir Sharif Jul 31 '16 at 18:58
  • i ran the following commands adb devices and then adb shell run-as com.example.mudasir.login and then ls -1 /data/data/com.example.mudasir.login/databases – Mudasir Sharif Jul 31 '16 at 19:00
  • My Manifest file shows this package name. package="com.example.mudasir.login" – Mudasir Sharif Jul 31 '16 at 19:22
  • Also checked "com.example.login". Same Issue..:( – Mudasir Sharif Jul 31 '16 at 19:23
  • App is installed on the device up and running. I also wonder why its showing unknow. Is it related to the permission denied..?? – Mudasir Sharif Jul 31 '16 at 19:37
  • Run this command "adb shell pm list packages" Check if you can find any app with name *mudasir* – guipivoto Jul 31 '16 at 19:44
  • Another point... right command is ( ls -l ) and not ( ls -1 ).. to avoid confusion, remove -l parameter.. run only ls /data/data/com.example.mudasir.login/databases – guipivoto Jul 31 '16 at 19:48
  • su command works to access the internal files of the device and now i can approach to /data/data/com.exmaple.mudasir.login/databases. And if i do ls, i can see my database file. But i issue is i cannot copy and pull the file from device to my computer. – Mudasir Sharif Aug 01 '16 at 17:15
  • I was wondering my device don't have any sdcard. Is it considering the internal storage of device as sdcard..? I try to use your given commands but its showing no result. :( – Mudasir Sharif Aug 01 '16 at 17:16
  • I spend last 2.5 hours on figuring out this problem. After spending the hours when i put my hands up and by chance i saw my internal storage folder, i saw one database file which was my database. I succeeded randomly and i don't know which solution make it happen. Now again stuck because I don't know which solution worked, – Mudasir Sharif Aug 01 '16 at 19:55
  • Please figure out for me because it got stuck into my mind. I know i am doing a little syntax mistake. And in the last it will make me feel like fool..:( – Mudasir Sharif Aug 01 '16 at 19:56
  • cp: /sdcard: Permission denied – Tshunglee Nov 02 '18 at 07:09