加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Android程序查询包含“*" "#”的号码时出错的解决措施

发布时间:2021-11-23 13:44:19 所属栏目:PHP教程 来源:互联网
导读:代码错误提示: E/AndroidRuntime(1145): Caused by: android.database.sqlite.SQLiteException: near *: syntax error: , while compiling: SELECT numbertype, new, duration, _id, numberlabel, name, number, type, date FROM calls WHERE (number = **9)
代码错误提示:
E/AndroidRuntime(1145): Caused by: android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT numbertype, new, duration, _id, numberlabel, name, number, type, date FROM calls WHERE (number = **9) ORDER BY date desc
 
解决:  
 
    strQuery = "number = " + strQueryNumber;  
            callLogCursor = TApplication.nowTApplication.getContentResolver()  
                    .query(CallLog.Calls.CONTENT_URI, null, strQuery, null,  
                            "date desc");                          
查询代码改成:  
 
                              
                                strQuery = "number = " + "'strQueryNumber'";  
            callLogCursor = TApplication.nowTApplication.getContentResolver()  
                    .query(CallLog.Calls.CONTENT_URI, null, strQuery, null,  
                            "date desc");  
总结:因为"*"为数据库里的关键字(未经证实),所有查找是会报语法错误,只需要拼接字符串,把"*"改成非关键字即可
 
ps:模拟器不知道为何直接拔打数字+"#"会清空屏幕,而只能拨打"#"开头的号码
 
 

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读