如何查看Android的SQLLite模拟器上的数据库 [英] How to view Android SQLLite database on emulator

查看:669
本文介绍了如何查看Android的SQLLite模拟器上的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了答案,关于这一主题previous的问题,但似乎无法得到其中的任何工作。我在Eclipse开发和运行在模拟器上的应用程序。

I've looked at answers to previous questions on this topic, but can't seem to get any of them to work. I am developing in Eclipse, and running the app on an emulator.

这似乎是最简单的方法是使用亚行外壳会同sqlite3的命令。与亚行,我可以看到模拟器设备。当我开始在亚行的shell,我看到一个目录这是我希望找到的数据库:

It seems like the simplest approach is to use the adb shell in conjunction with the sqlite3 command. With adb I can see the emulator device. When I start the adb shell, I see a directory which is where I would expect to find the database:

/data/data/com.example.myfirstapp/databases/  (where com.example.myfirstapp is the package name of the app)

不过,也有在该目录中没有 .db的文件。有具有相同名称的应用程序创建的数据库文件,但它不具备 .db的扩展。

However, there are no .db files in that directory. There is a file with the same name as the database the app created, but it does not have the .db extension.

(我pretty肯定我看到仿真设备的文件系统,因为它确实有我的应用程序的目录)。

(I'm pretty sure I am seeing the file system of the emulated device because it does have the directory for my application).

更新

在所有的反应会和访问通过ADB / sqlite3的数据库,并同样使用DDMD / SQLite的浏览器之后,我意识到我做了code一个新手错误:

After going through all the responses, and accessing the database via adb/sqlite3 and also using DDMD/Sqlite browser, I realized I made a "newbie" mistake in the code:

public class MessageOpenHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "MyFirstApp.db"; 
    public static final String MESSAGE_COLUMN = "message";
    public static final String MESSAGE_TABLE_NAME = "messages";   

    private static final String MESSAGE_TABLE_CREATE = String.format("create table %s (%s TEXT);", MESSAGE_TABLE_NAME, MESSAGE_COLUMN);

    public MessageOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);      
    }

按照惯例,数据库名称应该包括 .db的扩展。虽然它工作正常,没有它,Eclipse的sqlite的浏览器将无法识别该文件。希望其他新手像我不会再犯同样的错误。

By convention, the database name should include the .db extension. Although it works fine without it, the Sqlite browser for Eclipse won't recognize the file. Hopefully other neophytes like me won't make the same mistake.

推荐答案

您提到您使用的是Eclipse ...你可以去DDMS角度来看,选择Sqllite浏览器中的数据库文件和查看..如下图所示...

You mentioned you are using Eclipse ... You can go in DDMS perspective, select the db file and view in Sqllite Browser .. as shown below...

编辑: -
忘了提到我们需要在这里添加插件...

- Forgot to mentioned we require to add the plugin here...

按照链接这里

步骤: -


  1. 下载<一个href=\"https://dl.dropboxusercontent.com/u/91846918/sqlite%20manager/com.questoid.sqlitemanager_1.0.0.jar\"相对=nofollow> JAR文件

  2. 添加jar文件在Eclipse /的dropins /文件夹

  3. 重启Eclipse ..你会发现在DDMS透视图的图标..

这篇关于如何查看Android的SQLLite模拟器上的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆