I have 3 names, Allakhazam, Beatbox and Cunning in my NAMES Table.
public Cursor fetchNamesByConstraint(String filter) { mDb.query(true, DATABASE_NAMES_TABLE, new String[] { KEY_ROWID, KEY_NAME }, KEY_NAME + " LIKE ?", new String[] { filter }, null, null, null, null); return mCursor; }
I call the function with "A" as the filter, but my cursor is returning a 0 count when it should at least return me a 1. Anyone can see what's wrong with the code?
this statement will return all the records whose keyname equals string specified by string, if you use wild card, then you can get desired results. Like:
mDb.query(true, DATABASE_NAMES_TABLE, new String[] { KEY_ROWID, KEY_NAME }, KEY_NAME + " LIKE ?", new String[] { filter+"%" }, null, null, null, null);
Will Lists all the records starting with word in filter.
mDb.query(true, DATABASE_NAMES_TABLE, new String[] { KEY_ROWID, KEY_NAME }, KEY_NAME + " LIKE ?", new String[] {"%"+ filter+ "%" }, null, null, null, null);
Will Lists all the records containing word in filter.
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