i working on quiz app of sorts. in 1 section receive cursor sqlite db. contains id question, , order of question. want build quiz activity based on data linking question id sql query once figure out loop.
basically want able build activity first question based on cursor position , order number variable(1,2,3, etc). , each time answer question , click button iterate loop , go onto next cursor item , order number(question).
i stuck on how accomplish this.
cursor questionid_query = dbhelper.getquestionidlistfromchapterid(chapter_id);
i know have loop somehow, based on cursors count.
for(int i=0; < questionid_query.getcount(); i++){ // loop through cursor //build question list //listen button click }
basically tips on how accomplish nice, burnt out.
best approach think , working charm.
public arraylist<hashmap<string, string>> readrowsql(string rawsql, string[] rawsqlselectionarguments) { arraylist<hashmap<string, string>> list = new arraylist<hashmap<string, string>>(); cursor cursor = this.db.rawquery(rawsql, rawsqlselectionarguments); this.colcount = cursor.getcolumncount(); this.rowcount = cursor.getcount(); if (cursor.movetofirst()) { { hashmap<string, string> col = new hashmap<string, string>(); int size =cursor.getcolumncount(); (int = 0; < size; i++) { col.put(cursor.getcolumnname(i), cursor.getstring(i)); } list.add(col); } while (cursor.movetonext()); } if (cursor != null && !cursor.isclosed()) { cursor.close(); } return list; }