android 输入模糊匹配_Android 模糊搜索rawquery bind or column index out of range:
今天使用了android里面的sqlite的模糊查詢出錯了:
android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x580608
錯誤代碼:
String sql = "select * from " + TABLE_USER+
" where people_name like %?% or phone_number_text like %?% or office_number_text like %?% or family_number_text like %?%";
String [] selectionArgs = new String[]{search_context,search_context,search_context,search_context};
Cursor cursor = sqldb.rawQuery(sql, selectionArgs);
修改之后的代碼:
String sql = "select * from " + TABLE_USER+
" where people_name like ? or phone_number_text like ? or office_number_text like ? or family_number_text like ?";
String [] selectionArgs = new String[]{"%" + search_context + "%",
"%" + search_context + "%",
"%" + search_context + "%",
"%" + search_context + "%"};
Cursor cursor = sqldb.rawQuery(sql, selectionArgs);
注意:我開始的時候把"%" + search_context + "%"寫成了"%'" + search_context + "%'"也是錯誤的(多了一個')
0
頂
0
踩
分享到:
2012-10-21 17:48
瀏覽 4248
評論
總結
以上是生活随笔為你收集整理的android 输入模糊匹配_Android 模糊搜索rawquery bind or column index out of range:的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android数据回传多个页面_Andr
- 下一篇: python播放wav文件_python