Android : Android failes to call SQLite WHERE column LIKE '%?%' The statement has 0 parameters

on Friday, September 19, 2014


With this code



public static List<App> findByKeyword(Context context, String keyword){
ContentResolver resolver = context.getContentResolver();
Uri uri = getContentUri();
String[] projection = DataColumns.ALL;
String selection = DataColumns.NAME+" like '%?%' ";
String[] selectionArgs = {keyword};
Cursor cursor = resolver.query(uri, projection, selection, selectionArgs, DEFAULT_ORDER );
return cursorToList(cursor);
}


I get error



Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters.



The SQLite raw query should be SELECT * FROM table WHERE name LIKE '%?%' but there is problem of using parameter though ContentResolver query API


I also tried using " quotes



String selection = DataColumns.NAME+" like \"%?%\" ";


It also says



The statement has 0 parameters.



0 comments:

Post a Comment