Caused by: java.lang.IllegalStateException: get fi

2019-08-20 03:30发布

问题:

i want to select value from my database but i got error

Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed

i don't know where is the wrong in my code.. this is my code in dbHelper.

public Cursor pilihEnkripsi( String chiperteks ) {
    Cursor c = dba.rawQuery("SELECT idenkripsi FROM TB_enkripsi where chiperteks = '"+chiperteks+"'", null);
    return c;
}

and i want to get the value in other class. i use this code.

Cursor cursorEnkripsi = data.pilihEnkripsi(ciper);
    if(cursorEnkripsi.moveToFirst()) {
        idenkripsi = cursorKontak.getString(cursorKontak.getColumnIndex("idenkripsi"));
    }

can somebody help me? i really need the solution, please help me.. thanks.. Regards..

回答1:

Cursor cursorKontak should be cursorEnkripsi

Cursor cursorEnkripsi = data.pilihEnkripsi(ciper);
    if(cursorEnkripsi.moveToFirst()) {
        //idenkripsi = cursorKontak.getString(cursorKontak.getColumnIndex("idenkripsi"));
          idenkripsi = cursorEnkripsi.getString(cursorEnkripsi.getColumnIndex("idenkripsi"));
    }