Ejemplo n.º 1
0
  public List<Question> getQuestionSet(int difficulty, int numQ) {
    List<Question> questionSet = new ArrayList<Question>();
    Cursor c =
        myDataBase.rawQuery(
            "SELECT * FROM questions WHERE DIFFICULTY=" + 2 + " ORDER BY RANDOM() LIMIT " + numQ,
            null);
    while (c.moveToNext()) {
      // Log.d("QUESTION", "Question Found in DB: " + c.getString(1));
      Question q = new Question();
      q.setQuestion(c.getString(1));
      q.setAnswer(c.getString(2));
      q.setOption1(c.getString(3));
      q.setOption2(c.getString(4));
      q.setOption3(c.getString(5));
      AssetManager assetManager = myContext.getAssets();
      InputStream istr = null;
      try {

        istr = assetManager.open(c.getString(1) + ".png");
      } catch (IOException e) {
        e.printStackTrace();
      }
      Bitmap bitmap = BitmapFactory.decodeStream(istr);
      q.setBmp(bitmap);
      q.setRating(difficulty);
      questionSet.add(q);
    }
    return questionSet;
  }
Ejemplo n.º 2
0
 public List<Question> getQuestionSet(int difficulty, int numQ) {
   List<Question> questionSet = new ArrayList<Question>();
   Cursor c =
       myDataBase.rawQuery(
           "SELECT * FROM QUESTIONS WHERE DIFFICULTY="
               + difficulty
               + " ORDER BY RANDOM() LIMIT "
               + numQ,
           null);
   while (c.moveToNext()) {
     // Log.d("QUESTION", "Question Found in DB: " + c.getString(1));
     Question q = new Question();
     q.setQuestion(c.getString(1));
     q.setAnswer(c.getString(2));
     q.setOption1(c.getString(3));
     q.setOption2(c.getString(4));
     q.setOption3(c.getString(5));
     q.setRating(difficulty);
     questionSet.add(q);
   }
   return questionSet;
 }