自应用发布以来,我一直在使用Android Studio开发应用。

直到最近,一切都很好,我必须调试和检查数据库文件。由于我不知道如何直接看到数据库,当我调试生成数据库文件时,我不得不将数据库文件从我的手机导出到PC上。

为此,我必须打开DDMS >文件资源管理器。一旦我打开DDMS,我必须重新连接USB,我失去了调试线程。在检查数据库文件之后,我必须关闭DDMS并重新连接USB以回到调试模式。

这太复杂了。有人有更好的方法来做到这一点在Android Studio(我知道它更容易在Eclipse) ?


当前回答

如果你想在ANDROID STUDIO中浏览你的数据库,这是我正在使用的:

去文件/设置/插件,看看这个:

... 在重新启动Android Studio之后,你可以像这样选择你下载的数据库文件:

…点击“Open SQL Console”图标,你就会看到Android Studio中数据库的漂亮视图:

其他回答

我得把数据库从手机移到电脑上。现在我使用这个制作精良的免费应用程序,它有很多功能。它工作在API 4.1+与根设备。 如果你找到不用根也能吃的方法,请告诉我。

https://play.google.com/store/apps/details?id=com.lastempirestudio.sqliteprime

我把这个过程的unix命令行自动化放在一起,并把代码放在这里:

https://github.com/elliptic1/Android-Sqlite3-Monitor

它是一个shell脚本,以包名和数据库名作为参数,从附加的Android设备下载数据库文件,并针对下载的文件运行自定义脚本。然后,使用像“watch”这样的unix工具,你可以打开一个终端窗口,定期更新数据库脚本输出的视图。

试试这个android studio插件SQLScout。你可以实时查看和编辑你的应用程序数据库。

编辑:记住这是一个付费插件,但有24小时的试用,适合头痛的时候。

最后,Android Studio通过数据库检查器选项卡支持此功能。您可以轻松应用视图/更新/查询操作。它现在还不是稳定的渠道,但你可以尝试Android Studio 4.1 Canary 5或更高版本。

您可以在这里看到数据库检查器的样子

你可以在这里下载相应的版本

它是其他答案加加号的组合

Install DB Browser for SQLite Get the exact location from Device File Explorer for MyBase.db something like "/data/data/com.whatever.myapp/databases/MyBase.db" Set the project window from Android to Project - so you can see the files (build.gradle, gradle.properties,...etc) In Project window right click and chose Open in Terminal In terminal you are now in the root director of your application from the hardisk so execute: adb pull /data/data/com.whatever.myapp/databases/MyBase.db Now on the Project window of you Android Studio you have a file "MyBase.db" Double click your db file from Project and you can now browse/edit your databases in DB Browser When you are ready just do Write Changes in DB Browser so databases are saved on hardisk In terminal with the command: adb push MyBase.db /data/data/com.whatever.myapp/databases/MyBase.db you just send from the Hardisk to device the edited database.