代码错误提示:
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");总结:因为"*"为数据库里的关键字(未经证实),所有查找是会报语法错误,只需要拼接字符串,把"*"改成非关键字即可
ps:模拟器不知道为何直接拔打数字+"#"会清空屏幕,而只能拨打"#"开头的号码