【问题标题】:Get name and type from PRAGMA table_info()从 PRAGMA table_info() 获取名称和类型
【发布时间】:2013-02-06 04:20:39
【问题描述】:

在我的 android 应用程序中,我需要在执行命令 PRAGMA table_info(table_name) 后从结果中获取 name 和 type。我该怎么做?

【问题讨论】:

    标签: java android sqlite


    【解决方案1】:

    就这么简单(db 是您的 SQLiteDatabase 对象,tableName 应该设置为数据库中正确的表名):

    String tableName = ""; // your table name
    Cursor c = db.rawQuery("PRAGMA table_info(" + tableName + ")", null);
    if (c.moveToFirst()) {
        do {
            System.out.println("name: " + c.getString(1) + " type: " + c.getString(2));
        } while (c.moveToNext());
    }
    c.close();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-04
      • 1970-01-01
      • 2013-11-29
      • 2017-04-25
      • 2016-07-29
      • 1970-01-01
      相关资源
      最近更新 更多