android程序查詢包含"*" "#"的號碼時出錯的解決辦法代碼錯誤提示: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:模擬器不知道為何直接拔打數字+"#"會清空屏幕,而只能撥打"#"開頭的號碼