5 本帖最后由 vincy西西1010 于 2012-7-4 17:39 編輯 代碼錯誤提示:
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
解決:
1. strQuery = "number = " + strQueryNumber;
2. callLogCursor = TApplication.nowTApplication.getContentResolver()
3. .query(CallLog.Calls.CONTENT_URI, null, strQuery, null,
4. "date desc");
查詢代碼改成:
1.
2. strQuery = "number = " + "strQueryNumber";
3. callLogCursor = TApplication.nowTApplication.getContentResolver()
4. .query(CallLog.Calls.CONTENT_URI, null, strQuery, null,
5. "date desc");
總結:因為"*"為數(shù)據(jù)庫里的關鍵字(未經證實),所有查找是會報語法錯誤,只需要拼接字符串,把"*"改成非關鍵字即可ps:模擬器不知道為何直接拔打數(shù)字+"#"會清空屏幕,而只能撥打"#"開頭的號碼
|