java - Getting data with an array (or with another way) -


i have method takes answer id's (specific each answer) database answer table- getanswerid()

but want change it. created answer0,answer1, answer2 columns in question database , want take 0,1,2 answerid . how can identify getanswerid() ?

shortly;

name of columns :answer0,answer1,answer2

take "0,1,2" "answerid" , put in "getanswerid()"

then want use :

public int getanswerid() {

        return this.answerid; } 

edited:

sqlhelper:

final string query = "select " +             "answer._id, answerlang.answertext, answer.correct, " +             "answersquestions.questionid" +             " answersquestions" +             " inner join answerlang" +             " on answersquestions.answerid = answerlang.answerid" +             " inner join answer" +             " on answerlang.answerid = answer._id" +             " answersquestions.questionid in ( " +             allquestionids +             " )  order answersquestions.questionid ";     this.cursor = this.db.rawquery(query, null);      if (this.cursor.movetofirst()) {         {             (final question q : questions) {                 if (q.getquestionid() == this.cursor.getint(3)) {                     q.addanswer(new answer(this.cursor.getint(0),                             this.cursor.getstring(1),                             (this.cursor.getint(2) == 1 ? true : false)));                 }             }         } while (this.cursor.movetonext());     }     this.cursor.close(); 

this.cursor.getint(0) takes answer._id (_ids answer table)

i changed database structure , added answer0, answer 1, answer 2 answerlang table. need id each answers in 1 table. thought take questionid , 0 (or 1,2) (from answer0,1,2) answerid = questionid+0 spesific each answer

problem how interval questionid+0 go place, instead of this.cursor.getstring(0)

// // // // \ \ \ \

sumamry of question :

 use **this.sample.getint()** instead of this.cursor.getint(0) example:      this.sample.getint() : have interval 10,11,12 question 1 (questionid=1, answer0=0 answer0 id = 10, answer1 id = 11, answer2 id = 12  spesific id )       have interval 20,21,22 question 2 (questionid=2, answer0=0 answer0 id = 20 ...... spesific id ) 

assuming when questionid=1 , answerfromdb="answer1" can fist pass question id method , contact questionid , integer answerid new string , parse integer result 11 in case. if questionid=1 , answerfromdb="answer2" answerid 12 etc..

public int getanswerid( string questionid) { //here questionid=0 or 1 or 2 etc in string format  string newanswerid=questionid+answerfromdb.substring(8)   return integer.parseint(newanswerid);     } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -