怎样对android开发中的sqlite数据库进行模糊查询,并返回一个Cursor
返回Cursor是为了放在SimpleCursorAdapter里方便
返回Cursor是为了放在SimpleCursorAdapter里方便
答案:// select * from users where name like %searcherFilter% or telnumber like %telnumber%;
public List<HashMap<String, Object>> queryByLike(String searcherFilter) {
Cursor cursor = db.query(TABLE_NAME, null, "name like '%" + searcherFilter + "%' or telnumber like '%" + searcherFilter + "%'", null, null, null, null);
------------------------------------------------------------------------------------------------------------------------
这个是不是你要的!!
其他:SQLiteOpenHelper dbHelper=new MyDateBase(AndroidProject_SQLiteActivity.this,"myDataBase2");
SQLiteDatabase db=dbHelper.getReadableDatabase();
Cursor cur=db.query("user", new String[]{"id","name"}, "id like ?", new String[]{"%2%"}, null, null, null);
while(cur.moveToNext()){
String name=cur.getString(cur.getColumnIndex("name"));
System.out.println("查询出来的值是:"+name);
}
上一个:shell脚本中如何连接sqlite,原先的脚本是将数据传送到syslog服务器里,现在想改成记录到sqlite数据库中,
下一个:php打开sqlite数据库时提示:file is encrypted or is not a database,无法打开数据库。