打开一个后出现光标索引越界错误 数据库 。请任何人告诉我如何打开现有数据库 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();
}
最佳答案
这样做:
int index = 0;
if(c.moveToFirst())
index = c.getColumnIndex("COL_FirstName");
关于android - 游标索引越界异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9738851/