Android Java.Lang.Illegalstateexception: Couldn't Read Row 0, Col 0 from Cursorwindow

Android SQLIte error: Couldn't read row 0, col 1 from CursorWindow

Column indices start from 0. Your cursor has only 1 column, so replace getString(1) with getString(0) to access the only column value there is.

ERROR: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is correctly initialized before accessing data

Apparently, there is no studentname column in your result set, if c.getColumnIndex("studentname") is returning -1.

Couldn't read row 0, col 5 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it

Your cursor has one column SELECT NOTEMEMOS but you're trying to read the sixth one with getString(5). Replace that with getString(0) to read the only column value.

how to fix java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.

thanks everyone , it solve with this code

  public Penyakit getPenyakit1(String namaGejal){
SQLiteDatabase db = this.getReadableDatabase();
String[] colums = {nomber,namapen,idPen,namaGej,idGej};
String selection = namapen + " = ?";
String[] selectionArgs = {String.valueOf(namaGejal)};
Cursor cursor = db.query(TABLE_CONTACTS, colums, selection,
selectionArgs, null, null, null);
Penyakit penyakit = new Penyakit();
if (null != cursor) {
cursor.moveToFirst();
penyakit.set_nomber(cursor.getInt(0));
penyakit.set_namaPen(cursor.getString(1));
penyakit.set_idPenyakit(cursor.getInt(2));
penyakit.set_namGej(cursor.getString(3));
penyakit.set_idGejala(cursor.getInt(4));

}else{
penyakit=null;
}
db.close();
return penyakit;
}

android java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow

01-29 13:41:56.520: W/CursorWindow(4121): Window is full: requested allocation 5140987 bytes, free space 2096617 bytes, window size 2097152 bytes

Android SQLite returns rows in cursor windows that have the maximum size of 2MB as specified by config_cursorWindowSize. If your row exceeds this limit, you'll get this error.

Storing large data in sqlite database is not a good idea anyway. Store files in filesystem and paths in database.

java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow

This should be

 String username= result.getString(0);
String password=result.getString(1);

Cursor index starts from zero

Full code

SQLiteDatabase myDatabase=openOrCreateDatabase("Login",MODE_PRIVATE,null);
Cursor result=myDatabase.rawQuery("Select * from Login",null);
if (result.moveToFirst()) {
String username= result.getString(0);
String password=result.getString(1);
}


Related Topics



Leave a reply



Submit