Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错
做模糊搜索时,出现了 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 报错的更多相关文章
- 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 ...
- Column Index out of range, 2 > 1 列索引的范围,2 > 1。
Column Index out of range, 2 > 1 列索引的范围,2 > 1.这个问题是进行数据库查询的时候出现的. 因为查询sql语句时 只查询了 name 然后whil ...
- Android调用 .Net Core WebApi 返回数据,用FastJSON解析一直报错。
问题描述:.Net Core WebApi中用Newtonsoft.Json 把datatable转成json字符串,如:JsonConvert.SerializeObject(table,Forma ...
- 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 ...
- 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文件 解 ...
- Android 解决安装Egit时Egit Mylyn和org.eclipse.team.core报错
为了让Aptana支持GitHub,需要安装Egit,但在的时候碰到两个错误,一个是关于缺少EGit Mylyn另一个是缺少org.eclipse.egit.import.feature.group. ...
- 解决 在Android开发上使用KSOAP2上传大图片到服务器经常报错的问题
原文首发我的主力博客 http://anforen.com/wp/2017/04/android_ksoap2_unexpected_type_position_end_document_null_j ...
- eclipse里index.jsp头部报错的原因和解决方法
index.jsp的头<%@这句报错的话,是因为没有引入Tomcat的原因.解决:A:Window---Preferences---server---RuntimeEnviroments--Ad ...
- 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 ...
随机推荐
- spring-boot整合shiro实现权限管理
1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springBo ...
- bzoj4397【Usaco2015 Dec】Breed Counting(前缀和、树状数组)
题目描述 Farmer John's N cows, conveniently numbered 1…N, are all standing in a row (they seem to do so ...
- jdk8的stream流式计算的操作
jdk8之后增加了流式计算,现在根据学习了流式计算,并把过程记录下来: Person.java的bean package com.zhang.collectordemo; /** * @program ...
- jsp的课设1
记这个为了巩固整个网站的开发流程,java开发太昂贵基本上很少有公司用,不知道学校怎么想的用这个.基本流程适用于任何后台的开发. JDK的安装不提了,Tomcat和Mysql都是用的最新版的,由于是w ...
- pdf兼容问题不能正常预览
刚开始以为是这个PDF文件过大导致的 发现其他更大的文件也能正常显示 考虑到PDF的兼容问题 由于导出的PDF格式不兼容导致,如果有这种情况,可以尝试用word2016打开pdf文件,再导出成pdf.
- appium常见问题10_MAC_终端输入aapt指令报错提示"command not found"
问题: MAC终端使用aapt指令"aapt dump badging xxx/xxx/xxx.apk"查看apk包名和activity时报错提示"command not ...
- Html5 学习笔记 --》html基础 css 基础
HTML5 功能 HTML5特点 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta cha ...
- eclipse搭建jmeter编译环境(Jmeter二次开发)
jmeter是开源项目,方便大家对代码进行改动. 写了一个简单教程,帮助入门者进行搭建jmeter编译环境! 下载地址 文件格式为zip,解压后为docx微软office2007文档. 或者直接访问我 ...
- css中的文本字间距离、行距、overflow
css字间距.div css字符间距样式实例1.text-indent设置抬头距离css缩进 div设置css样式text-indent : 20px; 缩进了20px 2.letter-spacin ...
- 《代码大全2》读书笔记 Week 1
<代码大全2>第一.二.三章 隐喻思维在西方是一个热门的话题,隐喻的认知功能在各个学科正受到越来越多的重视,依照我的理解,其实就是以众所周知或者理解主体熟悉的事物为符号去将新事物.新概念具 ...