我有一个需要从数据库答案表 - getAnswerId()一个数组(或其他方式)获取数据
回答的ID(具体每个答案),但我想改变它的方法。我在问题数据库中创建了answer0,answer1,answer2列,并且想要将0,1,2作为answerId。我怎样才能识别它的getAnswerId()?
不久;列
名称:answer0,ANSWER1,ANSWER2
以 “0,1,2” 为 “answerId”,并把它放在 “getAnswerId()”
然后我想使用它像:
公众诠释getAnswerId(){
return this.answerId; }
EDITED:
提供SQLHelper:
final String query = "SELECT " +
"answer._id, answerlang.AnswerText, answer.Correct, " +
"answersquestions.QuestionID" +
" FROM answersquestions" +
" INNER JOIN answerlang" +
" ON answersquestions.AnswerID = answerlang.AnswerID" +
" INNER JOIN answer" +
" ON answerlang.AnswerID = answer._id" +
" WHERE answersquestions.QuestionID IN (" +
allQuestionIds +
") ORDER BY answersquestions.QuestionID ";
this.cursor = this.db.rawQuery(query, null);
if (this.cursor.moveToFirst()) {
do {
for (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)取answer._id(从答案表_ids)
我改变数据库结构并添加了答案0,答案1,答案2答案朗表。 所以我需要一个表中的每个答案的id。 我认为采取QuestionID和(或1,2-)(来自answer0,1,2) 所以answerID = QuestionID + 0将spesific每个答案
问题是如何间隔QuestionID + 0去的地方,而不是this.cursor.getString(0)
// // // // \ \ \ \
的Sumamry我的问题:
use **this.sample.getInt()** instead of this.cursor.getInt(0)
for example:
this.sample.getInt() : will have interval 10,11,12 for question 1 (QuestionID=1, answer0=0 so answer0 id = 10, answer1 id = 11, answer2 id = 12 as spesific id)
will have interval 20,21,22 for question 2 (QuestionID=2, answer0=0 so answer0 id = 20 ...... as spesific id)
我可以建议你更好地构建问题吗?我不太确定你在问什么。 – BlackBox 2013-03-18 10:47:19
你想获取列的值? – Sajmon 2013-03-18 10:50:03
请清楚提问,以便我们可以帮到您。 – Abx 2013-03-18 10:50:27