我在我的Android項目中有一個表,有3列,我只想從表中的主要活動中的一列(字符串值)中獲取特定值.. 我使用此代碼但它返回整個列表,我只是想根據條件一個值從光標檢索一個字符串值
公開名單getAlltableList(){
List <AI_TABLE> tableArrayList = new ArrayList <AI_TABLE>();
String selectQuery = "SELECT * FROM " + AI_TABLE;
Log.d (TAG, selectQuery);
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery (selectQuery, null);
// looping through all rows and adding to list
如果(!c.isAfterLast())
c.moveToFirst();
while (!c.isAfterLast()){
AI_TABLE table = new AI_TABLE();
table.ID = c.getInt(c.getColumnIndex(ID));
table.Q = c.getString(c.getColumnIndex(Q));
table.Q_ID = c.getString(c.getColumnIndex(Q_ID));
table.A = c.getString(c.getColumnIndex(A));
// adding to Students list
tableArrayList.add(table);
c.moveToNext();
}
return tableArrayList;
}
你已經寫了查詢,它會返回你所有的數據表,根據你的需要修改你的查詢 –
我應該用什麼來代替列表? –