lundi 29 juin 2015

Hi guys!. I have that error cursor index out of bounds exception [duplicate]

This question already has an answer here:

My cursor uses here! I have tried many times :D. I am beginner

 public NotePad getNote(int id){
       SQLiteDatabase db = this.getReadableDatabase();
       Cursor cursor = db.query(TABLE_NAME,new String[]{TITLE,TEXT,DATE,STATE},
               NOTE_ID +"=?", new String[]{String.valueOf(id)},null,null,null,null);
       if(cursor!=null)
           cursor.moveToFirst();
       NotePad notePad = new NotePad(cursor.getString(1), cursor.getString(2),
               cursor.getString(3), Integer.parseInt(cursor.getString(4)));
       cursor.close();
       db.close();
       return notePad;
    }

error in line

NotePad notePad = new NotePad(cursor.getString(1), cursor.getString(2),
               cursor.getString(3), Integer.parseInt(cursor.getString(4))); 

Aucun commentaire:

Enregistrer un commentaire