Using selectionArgs doesn't work in a query
android, sqlite
Solution
You have to append the % to the selectionArgs itself:
selectionArgs = new String[] { searchString + "%" };
Cursor c = db.rawQuery("SELECT column FROM table WHERE column=?", selectionArgs);
Note: Accordingly % and _ in the searchString string still work as wildcards!
Problem
I'm trying to use the following: ``` String dbquery = "Select * From stops where stopname LIKE '%?%' LIMIT 100"; String[] uinputarray = {uinput}; Cursor c = sDB.rawQuery(dbquery, uinputarray); ``` This consistently crashes. Curiously, if I use the old test code of: ``` Cursor c = sDB.rawQuery("Select * From stops where stopname LIKE '%" + uinput + "%' LIMIT 100", null); ``` It works flawlessly. I've been reading up on selectionArgs and I honestly can't see anything wrong with what I've done. What am I doing wrong? Thanks guys