I am getting a Cursor Index out of bounds error after opening a database . Please can any one tell me how to open an existing database in sqllite - Android . I want to fire a select query on the database and retrieve some information ?
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();
}
You must uncomment c.moveToFirst().
Here an example:
do it like this: