zeenat Romana zeenat Romana - 7 months ago 8
SQL Question

Developing simple Quiz application with Local Sqlite databese but score not incress

Score not increase...how to fix this problem i am using local sqlite databse
quesion fetch from database correctly display on view the only problem is that it not incress the score ..dont give me correct resut

RadioGroup grp = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton answer = (RadioButton) findViewById(grp.getCheckedRadioButtonId());
Log.d("yourans", currentQ.getANSWER()+" "+answer.getText());
//problem is here score not incress ...
if (currentQ.getANSWER().equals(answer.getText())) {
score++;
Log.d("score", "Your score" + score);
}
if(qid<5){
currentQ=quesList.get(qid);
setQuestionView();
}else{
Intent intent = new Intent(MainActivity.this, ResultActivity.class);
Bundle b = new Bundle();
b.putInt("score", score); //Your score
intent.putExtras(b); //Put your score to your next Intent
startActivity(intent);
finish();
}

Answer

You are checking if the given answer (Letter A, B, C) is equal to the correct answers text. Your code increasing the score will never get called. answer.getText() does not return a single letter, it will give you the answers text. currentQ.getANSWER() instead will just give you the single letter the user selected.

Comments