作者:天使装着幸福 | 来源:互联网 | 2023-05-24 13:33
我使用的是最新版本的Android Studio.当我在模拟器上运行我的应用程序时,我可以通过以下方式查看我的数据库:
tools -> Android Device Monitor -> clicking on the emulator in the left panel -> file explorer -> data -> data -> com.project-name
但是在设备上运行我的应用程序时,此选项不可用.
我检查过相关问题:
Android - 在设备上查看SQLite数据库?这里投票最多的答案建议将数据库复制到SD卡,甚至是eclipse.
在Android设备上访问sqlite数据库
这些问题来自2011年和2010年.我可以使用任何插件或其他外部工具吗?
1> Shubham A...:
通过ADB Shell连接到Sqlite3
我还没有找到任何方法在Android Studio中执行此操作,但我使用远程shell访问数据库而不是每次都拉取文件.
在此处查找所有信息: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-将shell连接到您的设备:
C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell
4-导航到包含db文件的文件夹:
cd data/data//databases/
5-运行sqlite3连接到你的db:
sqlite3 .db
6-运行你喜欢的sqlite3命令,例如:
Select * from table1 where ...;
注意:查找下面要运行的更多命令.
SQLite cheatsheet
在SQLite数据库中查看表有几个步骤:
列出数据库中的表:
.tables
列出表格的外观:
.schema tablename
打印整个表格:
SELECT * FROM tablename;
列出所有可用的SQLite提示命令:
.help
来源:这个 SO答案..