我正在尝试在sqlite中使用正则表达式搜索数据库。以下是我的代码:
cursor = db.rawQuery("SELECT _id, employee FROM employees WHERE employee REGEXP ?",
new String[]{"%" + prepareSearchText() + "%"});
adapter = new SimpleCursorAdapter(
this,
R.layout.search_row,
cursor,
new String[] {"_id", "employee "},
new int[] {R.id.idField, R.id.nameField});
setListAdapter(adapter);
然而,我遇到了这个错误:
Caused by: android.database.sqlite.SQLiteException: no such function: REGEXP.
我之前在 MySQL 中使用了 REGEXP 函数,所以我认为它也存在于 sqlite 中,但很显然并不是这样的。
在 Android 中查询 sqlite 数据库时,最好的正则表达式执行方式是什么?