Android - 如何查看在我的应用程序中创建的 sql 数据库?我在 Eclipse 中的 Android 模拟器上运行它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9846336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - How can I view a sql database created in my app? I'm running it on the Android emulator in Eclipse
提问by Tim
I have an Android application that uses the Android database to create tables and store data. I'm currently running this app in the emulator in Eclipse. I have 2 questions:
我有一个 Android 应用程序,它使用 Android 数据库来创建表和存储数据。我目前正在 Eclipse 的模拟器中运行这个应用程序。我有两个问题:
- Where can I find the actual database file (it must be on my computer somewhere right?) that is created when I run my app in the emulator?
- Is there an easy way to view what is in my database/tables?
- 我在哪里可以找到在模拟器中运行我的应用程序时创建的实际数据库文件(它必须在我的计算机上的某个地方?)
- 有没有一种简单的方法可以查看我的数据库/表中的内容?
If I could find where the actual database file is (if there is such a thing) on my computer, then perhaps question 2 would be answered as easily as opening that file. But I really have no clue. Any help is appreciated.
如果我能在我的计算机上找到实际数据库文件的位置(如果有这样的东西),那么问题 2 的回答可能就像打开那个文件一样容易。但我真的没有头绪。任何帮助表示赞赏。
回答by Taras Feschuk
Hi
你好
1. In the Eclipse look at the File Explorer tab (near the Console tab). Or look at menu "Window -> Show View -> Other... -> File Explorer". Emulator should be run. In the File Explorer window go to the folder "data/data/[your_package_name]/databases/". There you can find your database. You can export it to the your computer. At the right top corner of the window there is a button "pull a file from device". Select database, click that button and save a database on the computer.
1. 在 Eclipse 中查看 File Explorer 选项卡(靠近 Console 选项卡)。或者查看菜单“窗口 -> 显示视图 -> 其他... -> 文件资源管理器”。应该运行模拟器。在文件资源管理器窗口中,转到文件夹“data/data/[your_package_name]/databases/”。在那里你可以找到你的数据库。您可以将其导出到您的计算机。在窗口的右上角有一个按钮“从设备中提取文件”。选择数据库,单击该按钮并在计算机上保存一个数据库。
2. Program "sqlite browser" can shows a data in the database. You can download it here. It is easy to use.
2.程序“sqlite浏览器”可以显示数据库中的数据。你可以在这里下载。这个用起来很简单。
回答by Paul Drummond
The database is stored in the following location on the emulator (assuming your app has the package com.example.app
and a database named db-name.db
):
数据库存储在模拟器上的以下位置(假设您的应用程序具有包com.example.app
和名为 的数据库db-name.db
):
/data/data/com.example.app/db-name.db
You can access it from the command line as follows:
您可以从命令行访问它,如下所示:
cmd> adb -e shell
cmd> sqlite3 /data/data/com.example.app/databases/db-name.db
sqlite> select * from table_name;
sqlite> 1|Example Item 1|1|
sqlite> 2|Example Item 2|2|
sqlite>
回答by kmb64
If you want to browse your databases inside eclipse follow these instructions taken from here:
如果您想在 eclipse 中浏览您的数据库,请按照以下说明操作:
Android - 如何查看在我的应用程序中创建的 sql 数据库?我在 Eclipse 中的 Android 模拟器上运行它
1.Download the Questoid Plugin
1.下载Questoid插件
2.Place the file in your Eclipse plugins folder (e.g. /usr/lib/eclipse/plugins)
2.将文件放在 Eclipse 插件文件夹中(例如 /usr/lib/eclipse/plugins)
3.Restart Eclipse
3.重启Eclipse
4.Start up an Android Emulator w/ Debugging in Eclipse
4.在 Eclipse 中启动带有调试功能的 Android 模拟器
5.Switch to the DDMS Perspective in Eclipse
5.在Eclipse中切换到DDMS透视图
6.Go to the 'File Explorer' tab to locate your device's database file
6.转到“文件资源管理器”选项卡以找到设备的数据库文件
7.Navigate to: e.g. 'data -> data -> com.myproject -> databases -> myproject
7.导航到:例如'data -> data -> com.myproject -> databases -> myproject
8.Open the database file in Questoid (see screen shot)
8.在Questoid中打开数据库文件(见截图)
9.Switch to the 'Questoid SQLite Browser' tab that appears
9.切换到出现的“Questoid SQLite Browser”选项卡
10.Switch to the 'Browse Data' sub tab
10.切换到“浏览数据”子选项卡
11.Select your table from the drop down menu
11.从下拉菜单中选择您的表
12.Browse your data here and onward into the digital sunset
12.在此处浏览您的数据并继续浏览数字日落