Previously I had a “do while” loop that works really well now.
This time I can’t get my “while” only loop to work.
|-----|-------|------|------|
|._id.|..INFO.|.DONE.|.LAST.|
|..1..|...A...|...N..|......|
|..2..|...B...|...Y..|..L...|<--- cursor.moveToFirst();
|..3..|...C...|...Y..|......|
|..4..|...D...|...Y..|......|
|..5..|...E...|...N..|......|
|..6..|...F...|...N..|......|
|-----|-------|------|------|
My Code is:
cursor = db.rawQuery("SELECT * FROM " +TABLE_NAME+" WHERE "+LAST+" LIKE '%L%'", null);
cursor.moveToFirst();
if (!cursor.getString(cursor.getColumnIndex(_id)).equals(Long.toString(rowcount)))
{
while(!cursor.isLast())
{
cursor.moveToNext();
Toast.makeText(context, "your message", Toast.LENGTH_LONG).show();
}
}
The loop is never entered into, I know this because my toast doesn’t pop up. I am just wondering why. I can do this another way, by using a “for” loop, but I am just wondering what I’ve done wrong with this while loop.
The query will only fetch the row which has the LAST value as ‘L’.
The remaining rows will not be fetched. Hence the condition is not reached.