在 Android Studio 中查看数据库文件的内容 [英] View contents of database file in Android Studio
问题描述
自从应用发布以来,我一直在使用 Android Studio 来开发我的应用.
I have been using Android Studio to develop my app since it's was released.
直到最近一切都很好,我必须在检查数据库文件的同时进行调试.由于我不知道如何直接看到数据库,所以我在调试生成数据库文件时,必须将数据库文件从手机导出到PC.
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.
为了做到这一点,我必须打开 DDMS >文件资源管理器
.打开 DDMS 后,我必须重新连接 USB,并且我丢失了调试线程.检查数据库文件后,我必须关闭DDMS并再次重新连接USB才能回到调试模式.
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.
太复杂了.有没有人有更好的方法在 Android Studio 中做到这一点(我知道在 Eclipse 中更容易)?
It's just too complicated. Does anyone have a better way to do this in Android Studio (I know it's easier in Eclipse) ?
推荐答案
终于找到了一个最简单的解决方案,不需要打开DDMS.
Finally, i found a simplest solution which do not need to open the DDMS.
实际上,解决方案是基于@Distwo 提到的,但不必那么复杂.
Actually, the solution is based on what @Distwo mentioned, but it don't have to be that complicated.
首先,记住你的数据库文件在设备中的路径,它应该是一样的.例如我的是:/data/data/com.XXX.module/databases/com.XXX.module.database
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.
第三,如果您遇到权限被拒绝或类似的情况,只需在上一个命令之前运行 adb root
.
Third, if you got Permission Denied or something like that, just run adb root
before the previous command.
这篇关于在 Android Studio 中查看数据库文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!