Q:

cursor count is 1 whereas the table has 3 rows

I m trying to populate sql table and then retrieve data from it.  Following is my code. 
public void addQuestion(Question quest)
{
    int id = 1;
    ContentValues values = new ContentValues();
    SQLiteDatabase db = this.getWritableDatabase();
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_QUEST1);
    onCreate(db);
    values.put(KEY_QUES, quest.getQuestion());
    values.put(KEY_ANSWER, quest.getAnswer());
    values.put(KEY_OPTA, quest.getOptA());
    values.put(KEY_OPTB, quest.getOptB());
    values.put(KEY_OPTC, quest.getOptC());
    db.insert(TABLE_QUEST1, null, values);
    System.out.println("Added in database: " + quest.getQuestion());
}

public ArrayList<Question> getAllQuestions() {
    System.out.println("getting rows 1");
    ArrayList<Question> quesList = new ArrayList<Question>();
    System.out.println("getting rows 2");
    Cursor cursor = null;
    SQLiteDatabase db = getReadableDatabase();
    System.out.println("getting rows ");
    cursor = db.rawQuery("SELECT * FROM " + TABLE_QUEST1, null);
    if (! cursor.moveToFirst()) {
        System.out.println("No data in the database ");
    } else {
        System.out.println("theres data in the database ");
        quesList = new ArrayList<Question>();
        do {
            System.out.print("total rows " + cursor.getCount());
            Question quest = new Question();
            quest.setID(cursor.getInt(0));
            quest.setQuestion(cursor.getString(1));
            quest.setAnswer(cursor.getString(2));
            quest.setOptA(cursor.getString(3));
            quest.setOptB(cursor.getString(4));
            quest.setOptC(cursor.getString(5));
            quesList.add(quest);
        } while (cursor.moveToNext());
        cursor.close();
    }
}

I have 4 rows of data in my table and I can see that with the print statement "added in database"
but when i actually read it the cursor just reads row 1 and moves out of the while loop.  what could potentially be wrong. 
tia

A:

Your code was absolutely fine except placing drop command in the loop.  As mentioned in the earlier comments, please make sure to avoid calling drop query each time and you'll find the result.