首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

android- 数据库 模糊搜索, 单引号 ’ 报错有关问题(SQLiteException: unrecognized token: “‘)

2012-08-24 
android- 数据库 模糊搜索, 单引号 ’ 报错问题(SQLiteException: unrecognized token: “‘)android- 数据库

android- 数据库 模糊搜索, 单引号 ’ 报错问题(SQLiteException: unrecognized token: “‘)
android- 数据库 模糊搜索, 单引号 ’ 报错问题(SQLiteException: unrecognized token: “‘)

cursor = MainActivity.this.getContentResolver().query(uri, new String[]{"display1"}, "display1"+" like" +" '%"+tempSearchContent+"%'", null, "date desc");这样进行模糊搜索,如果tempSearchContent 为 ‘(单引号),需要对 其进行转义
或者 使用selectionArgs 参数:

String like = "%" + tempSearchContent + "%";

cursor = MainActivity.this.getContentResolver().query(uri, new String[]{"display1"}, "display1 like?", new String[]{like}, "date desc");

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhjp4295216/archive/2010/11/23/6028849.aspx

热点排行