我想查詢從手機通話記錄的細節,我的查詢是像下面android.database.sqlite.SQLiteException:近「*」:語法錯誤:,在編譯:SELECT calls._id
Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " = " + number, null,Calls.DEFAULT_SORT_ORDER);
CallLogAdapter.PROJECTION包含呼叫日誌的一些字段(列)。
它工作正常,但在下面的情況下,它會強制關閉。
條件: - 如果撥號號碼開始*或#(如:* 1234567或#123457)和數字結束與*(如:1234567 *)
**ERROR LOG:**
10-14 14:54:50.425: INFO/Database(26307): sqlite returned: error code = 1, msg = near syntax error 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): Writing exception to parcel 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT _id, number, name, date, duration, new, type FROM calls WHERE (number = *674088888) ORDER BY date DESC 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:65) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:83) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:49) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:330) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at com.android.providers.contacts.CallLogProvider.query(CallLogProvider.java:129) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.content.ContentProvider$Transport.bulkQuery(ContentProvider.java:174) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:111) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at android.os.Binder.execTransact(Binder.java:320) 10-14 14:54:50.429: ERROR/DatabaseUtils(26307): at dalvik.system.NativeStart.run(Native Method) 10-14 14:54:50.429: DEBUG/AndroidRuntime(27470): Shutting down VM 10-14 14:54:50.429: WARN/dalvikvm(27470): threadid=1: thread exiting with uncaught exception (group=0x40015560) 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): FATAL EXCEPTION: main 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT _id, number, name, date, duration, new, type FROM calls WHERE (number = *674088888) ORDER BY date DESC 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158) 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114) 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330) 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): at android.content.ContentProviderProxy.query(ContentProviderNative.java:366) 10-14 14:54:50.433: ERROR/AndroidRuntime(27470): at android.content.ContentResolver.query(ContentResolver.java:262)
誰能幫助我。
感謝您的快速反應和其作品的罰款。謝謝你Hiral :) – VKJ
很高興知道這個.BTW,如果它對你有用,你應該接受答案。 – Hiral
+1像魅力一樣工作..謝謝@Hiral – Venky