java - How to use a string in rawquery? -


i'm creating app on android studio.i randomly question using getquestion cursor first id = 0(will change else later)

sqlitedatabase mydatabase = this.openorcreatedatabase("questions", mode_private, null); cursor getquestion = mydatabase.rawquery("select question questions id = '0' order random() limit 1",null); int questionindex = getquestion.getcolumnindex("question"); 

in same table there answer column.i answer of question randomly got getquestion query using this

cursor getanswer = mydatabase.rawquery("select answer questions question = ?"); 

i couldnt find how use question string , use in getanswer query.what should ?

just read both columns same query:

cursor getquestion = mydatabase.rawquery("select question, answer ..."); int questionindex = getquestion.getcolumnindexorthrow("question"); int answerindex   = getquestion.getcolumnindexorthrow("answer"); ... 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -