QuizBook icon indicating copy to clipboard operation
QuizBook copied to clipboard

App closes when dabatase question overs . Help

Open anshul0430 opened this issue 6 years ago • 2 comments

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.

anshul0430 avatar Jun 18 '18 13:06 anshul0430

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++)); }

SourabhMane avatar Mar 11 '20 06:03 SourabhMane

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.

78Ronin78 avatar Apr 03 '20 03:04 78Ronin78