做模糊搜索时,出现了  bind or column index out of range: handle 0x2fb180 报错

public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title =? ";
Cursor cursor = db.rawQuery(sql, new String[] {word});
return cursor;

实现精确匹配后,依葫芦画瓢的想制作模糊搜索,套用了SQL语句,不料出错

public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title like '%"+word+"%'";
Cursor cursor = db.rawQuery(sql, new String[] {word});
return cursor;

解决方法:

public Cursor getTitle(String word) throws SQLException{
String sql = "select * from contentinfo1 where title like '%"+word+"%'";
Cursor cursor = db.rawQuery(sql,null);
return cursor;

原因:更改语句之后用了+word+而非占位符 ?, 所以rawQuery第二个参数不知道和哪个对应故出现报错
 
进一步修改方案可以参照
http://stackoverflow.com/questions/5716543/android-sqliteexception-bind-or-column-index-out-of-range-problem
需要将第二个rawquery参数更改为NULL

Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错的更多相关文章

  1. java.sql.SQLException:Column Index out of range,0<1

    1.错误描述 java.sql.SQLException:Column Index out of range,0<1 2.错误原因 try { Class.forName("com.m ...

  2. Column Index out of range, 2 > 1 列索引的范围,2 > 1。

    Column Index out of range, 2 > 1  列索引的范围,2 > 1.这个问题是进行数据库查询的时候出现的. 因为查询sql语句时 只查询了 name 然后whil ...

  3. Android调用 .Net Core WebApi 返回数据,用FastJSON解析一直报错。

    问题描述:.Net Core WebApi中用Newtonsoft.Json 把datatable转成json字符串,如:JsonConvert.SerializeObject(table,Forma ...

  4. android studio 解析Excel数据格式导入poi-3.17.jar时的一系列报错及处理Failed resolution of: Ljavax/xml/stream/XMLEventFactory,duplicate entry: org/apache/xmlbeans/xml/stream/Location.class,GC overhead limit exceeded

    在org官网下载的poi jar包,导入到studio compile files('libs/poi-3.17.jar') compile files('libs/poi-ooxml-3.17.ja ...

  5. android The public type classname must be defined in its own file 报错

    The public type classname must be defined in its own file classname  为类名 错误提示,公用的类必髯有自己拥有独立.java文件 解 ...

  6. Android 解决安装Egit时Egit Mylyn和org.eclipse.team.core报错

    为了让Aptana支持GitHub,需要安装Egit,但在的时候碰到两个错误,一个是关于缺少EGit Mylyn另一个是缺少org.eclipse.egit.import.feature.group. ...

  7. 解决 在Android开发上使用KSOAP2上传大图片到服务器经常报错的问题

    原文首发我的主力博客 http://anforen.com/wp/2017/04/android_ksoap2_unexpected_type_position_end_document_null_j ...

  8. eclipse里index.jsp头部报错的原因和解决方法

    index.jsp的头<%@这句报错的话,是因为没有引入Tomcat的原因.解决:A:Window---Preferences---server---RuntimeEnviroments--Ad ...

  9. mysql 5.7 ERROR 1054(42S22) Unknown column 'password' in ‘field list’ 报错

    mysql 忘记密码 报错?ERROR 1054(42S22) Unknown column 'password' in ‘field list’原因:5.7版本下的mysql数据库下已经没有pass ...

随机推荐

  1. 各大漏洞平台及SRC的区别和如何批量刷漏洞

    批量刷漏洞: 01刷指纹->02刷原始漏洞->03刷CMS->04刷指定政府.教育->05刷众测平台->06刷SRC->07刷国内外.活动 搜索引擎: 百度.goo ...

  2. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 GSM Base Station Identification (点在多边形内模板)

    In the Personal Communication Service systems such as GSM (Global System for Mobile Communications), ...

  3. Codechef BINOMSUM

    题意:(复制sunset的)有\(T\)天,每天有\(K\)个小时,第\(i\)天有\(D+i−1\)道菜,第一个小时你选择\(L\)道菜吃,接下来每个小时你可以选择吃一道菜或者选择\(A\)个活动中 ...

  4. Visual Studio 2008 附加进程调试

    关于附加进程调试的问题: 在项目当中经常使用“附加到进程”来调试项目,感觉挺方便的.我们做的项目通常都会发布到IIS(特别是B/S),一可以直接通过地址栏输入地址就可以运行项目,不必去使用开发工具来打 ...

  5. [CSP-S模拟测试]:涂色游戏(DP+组合数+矩阵快速幂)

    题目描述 小$A$和小$B$在做游戏.他们找到了一个$n$行$m$列呈网格状的画板.小$A$拿出了$p$支不同颜色的画笔,开始在上面涂色.看到小$A$涂好的画板,小$B$觉得颜色太单调了,于是把画板擦 ...

  6. [CSP-S模拟测试]:次芝麻(数学)

    题目描述 小$K$和小$X$都是小次货.身为小次货,最重要的事情就是次啦!所以他们正在纠结如何分芝麻次.一开始,小$K$有$n$个芝麻,小$X$有$m$个芝麻.因为他们都想次更多芝麻,所以每次手中芝麻 ...

  7. 【Java架构:持续交付】一篇文章搞掂:持续交付理论

    一.持续集成.持续交付.DevOps概念,关系等 持续集成(Continuous integration/CI) 持续交付(Continuous delivery/CD) 持续部署() 持续 (Con ...

  8. 使用 jQuery 实现 radio 的选中与反选

    使用 jQuery 实现 radio 的选中与反选 我们知道在 Html 中当我们选中一个radio后,再次点击该 radio,那么该 radio 依然是一个选中的状态,但是有时我们需要实现这样的逻辑 ...

  9. Jmeter登录中的cookie问题

    Jmeter中发送多个http请求,由于后面的请求需要登录后才能获取到数据,所以前面先要发送登录请求. 登录时会写cookie到本地,后面的请求中会读取cookie中的JSESSIONID,若后面的请 ...

  10. VB - FSO的常见对象和方法

    1. set fs=wscript.createobject(“scripting.filesystemobject”) 这样就建立了fso的模型.如果要释放的话也很简单, set fs=nothin ...