mardi 26 mai 2015

Getting questions from SQLite Android

I am trying to make a multiple answer quiz. I followed this website: Simple Quiz Game

In the Multiple Activity, I add this:

    QuestionsDbHelper db = new QuestionsDbHelper(this);
    questionsList = db.getAllQuestions();
    currentQuestion=questionsList.get(questionId);

As you can see on the last line I get this error. In the QuestionsDbHelper, I have added the questions, but still cannot get them display on the Activity. I have described the Activity in the Manifest file. What I can understand from the Debug is that my Array is empty, but I have inserted the list of questions.

Any idea?

Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
            at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
            at java.util.ArrayList.get(ArrayList.java:304)
            at com.game.mlm.q2game.MultipleMode.onCreate(MultipleMode.java:36)

Aucun commentaire:

Enregistrer un commentaire