如何获得在Android上表中的列数组列表?数组、如何获得、列表、上表中

2023-09-12 09:40:42 作者:說忘就忘.

我以后code以获得一个表的可用列名的Andr​​oid?

I am after a code to get the available column names of a table in Android?

我看了看周围,并没有发现任何东西。

I looked around and didn't find anything.

推荐答案

这是一个简单的方法:

Cursor ti = db.rawQuery("PRAGMA table_info(mytable)", null);
if ( ti.moveToFirst() ) {
    do {
        System.out.println("col: " + ti.getString(1));
    } while (ti.moveToNext());
}