我正在使用最新版本的Android Studio。在模拟器上运行应用程序时,我可以通过以下方式查看数据库:
tools -> Android Device Monitor -> clicking on the emulator in the left panel -> file explorer -> data -> data -> com.project-name
但是在设备上运行我的应用程序时,此选项不可用。
我检查了相关问题:
这些问题来自2011年和2010年。我可以使用任何插件或其他外部工具吗?
我在Android Studio中没有找到实现此目的的任何方法,但是我使用远程外壳程序访问数据库,而不是每次都提取文件。
在此处找到所有信息:http : //developer.android.com/tools/help/adb.html#sqlite
1-在命令提示符下转到您的platform-tools文件夹
2-输入命令adb devices
以获取设备列表
C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb devices
List of devices attached
emulator-xxxx device
3-将外壳连接到设备:
C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell
4-导航到包含您的数据库文件的文件夹:
cd data/data/<your-package-name>/databases/
5-运行sqlite3以连接到您的数据库:
sqlite3 <your-db-name>.db
6-运行您喜欢的sqlite3命令,例如:
Select * from table1 where ...;
注意:查找更多命令以在下面运行。
有一些步骤可以查看SQLite数据库中的表:
列出数据库中的表:
.tables
列出表格的外观:
.schema tablename
打印整个表:
SELECT * FROM tablename;
列出所有可用的SQLite提示命令:
.help
资料来源:这个答案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句