Android的SQLite数据库模式 [英] Android Sqlite database schema

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

问题描述

我想我已经创建了一个数据库sqllite与Android,但我每次去做到这一点声称列不存在插入。我怎样才能查看架构并呼吁创建对象onCreate方法?

I think I have created an sqllite database with android but every time I go to do an insert it claims a column does not exist. How can I view the schema and is the onCreate method called on object creation?

推荐答案

您可以用code做到这一点。 sqlite的有一个叫SQLITE_MASTER表,该表holdes此信息。

You can do it with code. Sqlite has a table called "sqlite_master " which holdes this information.

/**
     * Get all table Details from teh sqlite_master table in Db.
     * 
     * @return An ArrayList of table details.
     */
    public ArrayList<String[]> getDbTableDetails() {
        Cursor c = db.rawQuery(
                "SELECT name FROM sqlite_master WHERE type='table'", null);
        ArrayList<String[]> result = new ArrayList<String[]>();
        int i = 0;
        result.add(c.getColumnNames());
        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            String[] temp = new String[c.getColumnCount()];
            for (i = 0; i < temp.length; i++) {
                temp[i] = c.getString(i);
            }
            result.add(temp);
        }

        return result;
    }

一个更简单的方法是在模拟器上运行它。

A more simple way is to run it on the emulator .


  1. 开启DDMS透视图

  2. 找到数据/数据​​/ PACKAGENAME /数据库/ YOURFILE

  3. 单击从数据库按钮,在显示画面右上角的拉动。

打开

Open

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

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