androidandroid-studioandroid-sqliteddms

View contents of database file in Android Studio


I have been using Android Studio to develop my app since it's was released.

Everything works nice until recently, I have to debug together with checking the database file. Since I don't know how to see the database directly, When I debugged to generate the database file, I have to export the database file from my phone to the PC.

In order to do this, I have to open DDMS > File Explorer. Once I open the DDMS, I have to reconnect the USB, and I lose my debug thread. After checking the database file, I have to close the DDMS and reconnect the USB again to get back to the debug mode.

It's just too complicated. Does anyone have a better way to do this in Android Studio (I know it's easier in Eclipse) ?


Solution

  • Finally, i found a simplest solution which do not need to open the DDMS.

    Actually, the solution is based on what @Distwo mentioned, but it don't have to be that complicated.

    First, remember the path of your database file in the device, it should aways the same. For example mine is:/data/data/com.XXX.module/databases/com.XXX.module.database

    Second, execute this command which pulls your database file onto you PC

     adb pull /data/data/com.XXX.module/databases/com.XXX.module.database /Users/somePathOnYourPC/
    

    What you need to do is just copy and store this command, then you can use it again and again.

    Third, if you got Permission Denied or something like that, just run adb root before the previous command.