【发布时间】:2011-09-01 05:49:47
【问题描述】:
我正在尝试使用 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数据库时执行正则表达式的最佳方法是什么?
【问题讨论】: