2016-06-07 87 views

回答

0

這是我使用的字符串來檢索列名:

SQLiteDatabase mDataBase; 
(some code here...) 
mDataBase = getReadableDatabase(); 
Cursor dbCursor = mDataBase.query(TABLE_NAME, null, null, null, null, null, null); 
String[] columnNames = dbCursor.getColumnNames(); 

或本:

Cursor c = db.rawQuery("SELECT * FROM table WHERE 0", null); 
try { 
    String[] columnNames = c.columnNames(); 
} finally { 
    c.close(); 
} 
0

列名在名爲name列返回:

... 
int nameColIdx = ti.getColumnIndexOrThrow("name"); 
... 
output.add(ti.getString(nameColIdx)); 
...