So here it goes, i have this application retrieves records from database, i have 5 entries from my database, and retrieved its using this code;
Cursor c = dbconnection.rawQuery("SELECT * from Patients", null);
after that i looped it to retrieve the data pero row in my Database as such;
c.moveToFirst();
while(!c.isAfterLast())
{
//Some code to put records per column in to a Patient Object
c.moveToNext();
}
So my problem is that as it enters the loop my Emulator freezes and as i tried to display per record into a Log, i won’t cuz the emulator it self already frozed.
Can somebody enlighten me into this matter, This issue is really really new to me
EDIT
yes already tried what baya and ofir suggested.. they worked out but i have this null error during iteration with this loop code
Cursor c = dbHelper.retrieveAllData();
c.moveToFirst();
while(c.moveToNext())
{
Log.d("dbcheck",Integer.toString(c.getPosition()));
//Log.d("dbcheck",c.getString(c.getColumnIndex("firstname")));
//Log.d("dbcheck",c.getString(c.getColumnIndex("lastname")));
**p.setFname(c.getString(c.getColumnIndex("firstname")));**
p.setMi(c.getString(c.getColumnIndex("middleinitial")));
p.setLname(c.getString(c.getColumnIndex("lastname")));
p.setAddr(c.getString(c.getColumnIndex("address")));
p.setAge(c.getInt(c.getColumnIndex("age")));
p.setMed_history(c.getString(c.getColumnIndex("med_history")));
p.setPat_status(c.getString(c.getColumnIndex("status")));
patientList.add(p);
}
i have a null exception error on the p.setFname() line.. i don’t know how it became null where in fact i already displayed it with Log using that code that is commented out..
Just try,