Get name and type from PRAGMA table_info()

后端 未结 1 1053
情深已故
情深已故 2021-01-06 18:16

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)

相关标签:
1条回答
  • 2021-01-06 18:43

    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();
    
    0 讨论(0)
提交回复
热议问题