Search code examples
androidsqlitecursor

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


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..


Solution

  • 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"));
        }