Pen*_*m10 8 java sqlite android
我正在使用代码来获取Android中表的可用列名?
我环顾四周,没有找到任何东西.
Die*_*ano 21
这是一种更简单的方法:
Cursor ti = db.rawQuery("PRAGMA table_info(mytable)", null);
if ( ti.moveToFirst() ) {
do {
System.out.println("col: " + ti.getString(1));
} while (ti.moveToNext());
}
Run Code Online (Sandbox Code Playgroud)
Zul*_*Zul 14
我实施的最简单的方法.
Cursor cursor = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 1", null);
String[] colNames = cursor.getColumnNames();
Run Code Online (Sandbox Code Playgroud)
欢迎任何更好的建议.