QuizBook
QuizBook copied to clipboard
App closes when dabatase question overs . Help
if (c2 == 0) { for (i = 1; i < 50; i++) { list.add(new Integer(i));
}
Collections.shuffle(list);
c2=1;
}
Ques = Sports.readQuestion(list.get(j));
Opta = Sports.readOptionA(list.get(j));
Optb = Sports.readOptionB(list.get(j));
Optc = Sports.readOptionC(list.get(j));
Optd = Sports.readOptionD(list.get(j));
global = Sports.readAnswer(list.get(j++));
}
If my database question are over then the app crashes.
To avoid this error you need to check the value of J counter, if J counter value is equal to nos of questions in list then create an intent and call Result activity to display result and in else part continue with the reading of questions and answer.
The above solution worked for me.
if (j == 50 ) { call Result activity } else { Ques = Sports.readQuestion(list.get(j)); Opta = Sports.readOptionA(list.get(j)); Optb = Sports.readOptionB(list.get(j)); Optc = Sports.readOptionC(list.get(j)); Optd = Sports.readOptionD(list.get(j)); global = Sports.readAnswer(list.get(j++)); }
To avoid this error you need to check the value of J counter, if J counter value is equal to nos of questions in list then create an intent and call Result activity to display result and in else part continue with the reading of questions and answer.
The above solution worked for me.
if (j == 50 ) { call Result activity } else { Ques = Sports.readQuestion(list.get(j)); Opta = Sports.readOptionA(list.get(j)); Optb = Sports.readOptionB(list.get(j)); Optc = Sports.readOptionC(list.get(j)); Optd = Sports.readOptionD(list.get(j)); global = Sports.readAnswer(list.get(j++)); }
Thanks, this work it me.