I want to retrieve notes from database where notes are (not null), I wrote the following code:
public Cursor getmynotesss(int id){
Cursor mCursor = database.query(true, NOTES_TABLE, new String[] {
NOTE_TEXT, PAGE_NO,BOOK_ID},BOOK_ID + "=? AND "+NOTE_TEXT+" IS NOT NULL OR "+NOTE_TEXT+" != ''" ,
new String[] { String.valueOf(id) }, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
but it still gives me the null notes. what is the wrong in my code?
It looks like the OR condition should be AND :
"=? AND "+NOTE_TEXT+" IS NOT NULL AND "+NOTE_TEXT+" != ''"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With