Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters.
Android 无法识别 ?%
中的 ?
字符
我努力做到这一点:
String selectQuery = "SELECT * FROM config WHERE Directory Like '?%';";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, new String[] {parent});
我已经搜索了一个解决方案,但找不到任何东西,我认为它非常特殊。我正在尝试这样做,因为我想让查询与包含字符 '
的 Strings
一起工作。
也许有同样问题的人可以回答我,我该如何解决。
最佳答案
使用||
连接参数和通配符:
SELECT * FROM config WHERE Directory Like ? || '%';
关于android - 不能在带有参数和 % 字符的 Android SQLite 中使用 Like 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33592565/