Android(安卓)Sqlite数据库查询操作使用 '%?%' 的问题
Sqlite数据库查询操作使用 '%?%' 的问题,
public static final String QUERY_DREAM_BY_CONDITION = "select * from Journal where description like ’%?%‘ ";
Cursor cursor = db.rawQuery(ConstantUtil.QUERY_DREAM_BY_CONDITION, new String[]{condition}); // condition为查询条件
02-15 16:41:34.633: E/AndroidRuntime(10789): Uncaught handler: thread main exiting due to uncaught exception
02-15 16:41:34.803: E/AndroidRuntime(10789): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x4dbad8
具体原因好像是编码的问题:
参考资料:
http://www.eoeandroid.com/forum.php?mod=viewthread&tid=2172
http://www.eoeandroid.com/thread-27411-1-1.html
解决办法,用两个 %%,且不能用在sql语句中 (select * from Journal where description like ’%%?%%‘ 这也是不行的)
public static final String QUERY_DREAM_BY_CONDITION = "select * from Journal where description like ?";
更多相关文章
- Android(安卓)解决多个通知发生冲突的问题
- 解耦问题
- Android(安卓)DownloadManager 使用
- 解决Could not find method android() for arguments问题
- Android打包常见问题
- Android(安卓)Studio开发过程中各种问题
- android解决Unknown host 'jcenter.bintray.com'问题
- Android抖动动画
- android dex工具打包Could not reserve enough space for object