本文介绍了从PRAGMA table_info获取名称和类型()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我需要获得名称键入从当我后我得到的结果执行命令 PRAGMA table_info(TABLE_NAME)。我怎样才能做到这一点?

In my android app, i need to get name and type from the result when i'm getting after execute the command PRAGMA table_info(table_name). how can i do this ?

推荐答案

这是这么简单(分贝 SQLiteDatabase 对象和 tableName值应设置为正确的表名的数据库中):

It's as simple as that (db is your SQLiteDatabase object and tableName should be set to the correct table name inside your database):

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();

这篇关于从PRAGMA table_info获取名称和类型()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:43