代碼錯誤提示:
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:模擬器不知道為何直接拔打數字+"#"會清空屏幕,而只能撥打"#"開頭的號碼
本文讨论了在Android应用中遇到的拨打电话时出现的SQLite语法错误问题,通过修改查询语句的方式成功解决了该问题。此外,文章还提到了在使用*作为查询条件时可能引发的问题,并提供了解决方法。
267

被折叠的 条评论
为什么被折叠?



