samedi 31 janvier 2015

sqlite "like" syntax didn't bring any results

I try to read from the sqlitDB with the following query:



public ArrayList<ReminderNote> getAllRegexItems(String author) {
ArrayList<ReminderNote> results = new ArrayList<>();

Cursor cursor = this.getReadableDatabase().query(
REMINDER_NOTE_TABLE,
new String[]{KEY_ID, KEY_NOTE, KEY_AUTHOR}, Strings.isEmpty(author) ? null : KEY_AUTHOR + " = ?",
Strings.isEmpty(author) ? null : new String[]{"%" + author + "%"}, null, null, null);


is it OK to use the % like i did?


If author is null or empty I want all the results to be fetched.


Unfortunately I get empty results set even though I added such entity beforehand.


and I can see non-empty results set when I execute:



Cursor cursor = this.getReadableDatabase().query(
REMINDER_NOTE_TABLE,
new String[]{KEY_ID, KEY_NOTE, KEY_AUTHOR}, null, null, null, null, null);

Aucun commentaire:

Enregistrer un commentaire