2
打開 數據庫後,出現遊標索引超出界限的錯誤。請任何人告訴我如何打開 sqllite - Android中的現有數據庫。我想在數據庫上啓動一個選擇查詢並檢索一些信息?遊標索引超出範圍
public void getPatient(SQLiteDatabase db, String name) {
// TODO Auto-generated method stub
db=this.getReadableDatabase();
//db.open();
System.out.println("in cursooooooooorrrrrrrrr");
Cursor c = db.rawQuery("SELECT * from table_patient WHERE COL_Name"+"=?",
new String []{name});
//c.moveToFirst();
int index = c.getColumnIndex("COL_FirstName");
System.out.println("First Name : ----------- "+c.getString(index));
c.close();
}
及其打印索引= 0。請你能告訴我如何檢查是否打開了正確的數據庫,以及數據庫中是否有數據 – Rish 2012-03-16 14:39:00
似乎你的查詢沒有返回任何記錄。嘗試改變你的查詢是這樣的:'Cursor c = db.rawQuery(「SELECT * FROM table_patient WHERE COL_Name LIKE?」,new String [] {name});'' – waqaslam 2012-03-16 14:42:47