Android sqlite query returns 0

senadxxx

New Member
The error appears when I apply the AND statement after the deckid. Basically the app is a set of cards and when you read through one it's marked complete. If I go with just KEY_CARDLINK + "=" + deckId it returns the next card in the deck but I don't want it to show the completed cards only the ones you haven't read but when I apply the + " AND " + KEY_COMPLETED + "=0" to the statement it always returns 0 as the next id which isn't the case. \[code\]public long getNextRecord(int next, long rowId, long deckId) { long nextRowId = 0; Cursor mCursor = mDb.query(CARDS_TABLE, new String[] {KEY_ROWID,KEY_CARDLINK,KEY_COMPLETED}, KEY_CARDLINK + "=" + deckId + " AND " + KEY_COMPLETED + "=0", null, null, null, null, null); if (mCursor.moveToFirst()) { do { if (mCursor.getLong(mCursor.getColumnIndexOrThrow(KEY_ROWID)) == rowId) { if (!mCursor.move(next)) { // first (-1) or last position if (mCursor.getPosition() == -1) { mCursor.moveToLast(); } else { mCursor.moveToFirst(); } } nextRowId = mCursor.getLong(mCursor.getColumnIndexOrThrow(KEY_ROWID)); break; } } while (mCursor.moveToNext()); } mCursor.close(); return nextRowId;}\[/code\]
 
Back
Top