I have a database called updateparty from which i have to create a array list of type hashmap string.When i try to retrieve data from db,the cursor does not move to next record.
Here is the code for db insertion.
for (int i = 0; i < poslist.size(); i++) {
SQLiteDatabase db7 = db.getWritableDatabase();
ContentValues values5= new ContentValues();
values5.put(DBManager.TableInfo.KEYID, ID1);
values5.put(DBManager.TableInfo.DOCU, document);
values5.put(DBManager.TableInfo.ATTEND,attendancelist.get(i));
values5.put(DBManager.TableInfo.EMAIL, emaillist.get(i));
values5.put(DBManager.TableInfo.PARTY,partytypelist.get(i) );
values5.put(DBManager.TableInfo.BIO,biometriclist.get(i));
values5.put(DBManager.TableInfo.KEY_LOGIN_USER,username2);
String condition5 = DBManager.TableInfo.DOCU + " =?";
Cursor cursor5 = db7.query(DBManager.TableInfo.UPDATEPARTY, null, condition5, new String[]{DBManager.TableInfo.ATTEND}, null, null, null);
long status5 = db7.insert(DBManager.TableInfo.UPDATEPARTY, null, values5);
System.out.println( "Parties insert : " + status5);
cursor5.close();
db7.close();
}
Code to create arraylist from above db:
public ArrayList<HashMap<String, String>>getPartypost(DBOperation db) {
ArrayList<HashMap<String, String>> listParties11 = new ArrayList<HashMap<String, String>>();
try {
String query = "select * from " + DBManager.TableInfo.UPDATEPARTY + " where " + DBManager.TableInfo.KEY_LOGIN_USER + " = '" + GenericMethods.email + "'";
System.out.println("query:"+query);
SQLiteDatabase sqlite1 = db.getWritableDatabase();
Cursor c = sqlite1.rawQuery(query, null);
while(c.moveToNext()) {
HashMap<String, String> selectiondetails10 = new HashMap<String, String>();
System.out.println("value:"+c.getString(c.getColumnIndex(DBManager.TableInfo.DOCU)));
selectiondetails10.put("document_id", c.getString(c.getColumnIndex(DBManager.TableInfo.DOCU)));
selectiondetails10.put("att_id", c.getString(c.getColumnIndex(DBManager.TableInfo.ATTEND)));
selectiondetails10.put("email", c.getString(c.getColumnIndex(DBManager.TableInfo.EMAIL)));
selectiondetails10.put("party_type", c.getString(c.getColumnIndex(DBManager.TableInfo.PARTY)));
selectiondetails10.put("biometric", c.getString(c.getColumnIndex(DBManager.TableInfo.BIO)));
selectiondetails10.put("exec_email", c.getString(c.getColumnIndex(DBManager.TableInfo.KEY_LOGIN_USER)));
listParties11.add(selectiondetails10);
}
closeCursor(c);
//}
// }
System.out.println("list size:"+listParties11.size());
} catch (Exception e) {
// TODO: handle exception.
e.printStackTrace();
}
db.close();
return listParties11;
}
This is the error message:
What i need is to create a arraylist from this db