android - error show cursor out of bound -
i'm show particular data listview bt doenot show emulator goes blank.... query as..
sqlitedatabase sd = db.getreadabledatabase(); string select = "select * pending_dues_table _pending_dues_id ="+i; cr = sd.rawquery(select, null); if (cr != null) { //cr.movetofirst(); int ii; ii=cr.getcolumnindex("pending_dues_notice"); while (cr.movetolast()){ namelist.add(cr.getstring(ii)); //studentno.add(cursor.getstring(1)); } } arraylist<string>combimelist=new arraylist<string>(); for(int j = 0; j<namelist.size();j++){ combimelist.add(namelist.get(j)); } adapter = new arrayadapter<string>(studentdues.this,r.layout.student_due, combimelist);
and locat show error as..
05-25 03:33:56.225: e/androidruntime(5134): fatal exception: main 05-25 03:33:56.225: e/androidruntime(5134): java.lang.outofmemoryerror: [memory exhausted] 05-25 03:33:56.225: e/androidruntime(5134): @ dalvik.system.nativestart.main(native method)
your logcat says
cursorindexoutofboundsexception: index 0 requested, size of 0 ...... @ com.example.mytryapp.teacherstudent$1.onclick(teacherstudent.java:57)
so think problem hare
if (get_rollno.equals(cr.getstring(0))) { loginstatus = true; name=cr.getstring(0); }
and suggestion check before call must have data. try hope works
if(cursor.getcount() > 0){ // values cursor here if (get_rollno.equals(cr.getstring(0))) { loginstatus = true; name=cr.getstring(0); } }
or there better way
try
cursor cursor = //query here while (cursor.movetonext()) { // retrieve values cursor }
if there problem ... comment it
Comments
Post a Comment