SQLite模糊查找(like)
来源:互联网 发布:侠盗无双0.4下载 软件 编辑:程序博客网 时间:2024/06/05 17:20
最近在做一个SRTP的项目,是有关android平台的。我想对此有些许了解的人都知道,android开发中存储数据的方法离不开SQLite数据库,android内置了SQLite数据库,同时也内置了许多数据库的操作语言,很方便。很多都还比较容易懂(看api)。个人觉得有点烦(每个人当然不一样)的是模糊查询这一块,下面是我从各个网站上搜到的,仅供参考。
(1)使用db.query方法查询
// select * from users where name like %searcherFilter% ;public List<HashMap<String, Object>> queryByLike(String searcherFilter) { Cursor cursor = db.query(TABLE_NAME, null, "name like '%" + searcherFilter + "%'", null, null, null, null); 或者 Cursor cursor = db.query(TABLE_NAME, null, "name like ?", new String[]{"%"+searcherFilter+"%"}, null, null, null); }(2)使用Cursor cursor=db.execure("select * from table_name where name like '%"+searcherFilter "%'")
在使用完Cursor后,要关闭Cursor,cursor.close();
如果不关闭,虽然前台不会force close,但后台会报错:DatabaseObjectNotClosedE
在使用完SQLiteDatabase后,同样需要关闭。db.close();
否则报错如Cursor。
但两者报错时点不同。不关闭Cursor的话,在调用新的Activity时就会报错。
而不关闭SQLiteDatabase的话,在推出程序,重新进入时就会报错
- SQLite模糊查找(like)
- c# sqlite中的like 模糊查询参数
- 模糊查找 再深入 sqlite
- SQL 模糊查询(like)
- hibernate使用LIKE进行模糊查找,并实现分页
- MySQL的模糊查询(like)
- MySql语句(Like模糊匹配)
- 模糊查询like小结
- jpa like模糊查询
- linq Like 模糊查询
- SQL like 模糊查询
- like 模糊查询
- ibatis模糊查询(like)
- oracle like模糊查询
- SQL like 模糊查询
- SQL like 模糊查询
- like模糊查询
- oracle like 模糊查询
- Apache 的 httpd.conf 详解
- 正则表达式函数详解
- ucos代码阅读(3)
- 在 Debian 上源码编译和安装 Nginx+PHP+FastCGI+MySQL
- How-to Guide: Perfect Windows Defender Uninstall
- SQLite模糊查找(like)
- VIM 高阶
- CLR线程池的工作者线程
- 写在研究生入学之前
- typedef和#define的区别
- 双击jar包出现:could not find the main class .和could not create the java virtual machine.win7/xp解决方法详解
- 经典递归应用--汉诺塔(C#语言版)
- Using Images as Buttons on Windows Phone 7
- 苹果开发者成惊弓之鸟:一封邮件引发的风波