I want to query the call log details from phone, my query is like below
我想从手机查询通话记录详细信息,我的查询如下
Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " = " + number, null,Calls.DEFAULT_SORT_ORDER);
CallLogAdapter.PROJECTION contain some fields(columns) of call log.
CallLogAdapter.PROJECTION包含呼叫日志的一些字段(列)。
It works fine, but in below condition it will give force close.
它工作正常,但在以下情况下,它会给力关闭。
Condition:-If dial number starting with * or # (ex: *1234567 or #123457) and number end with * (ex: 1234567*)
条件: - 如果拨号号码以*或#开头(例如:* 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)
10-14 14:54:50.425:INFO / Database(26307):sqlite返回:错误代码= 1,msg =接近语法错误10-14 14:54:50.429:ERROR / DatabaseUtils(26307):向包裹10写入异常-14 14:54:50.429:ERROR / DatabaseUtils(26307):android.database.sqlite.SQLiteException:near“*”:语法错误:,同时编译:SELECT _id,number,name,date,duration,new,type FROM调用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):在android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)10-14 14:54:50.429:ERROR / DatabaseUtils(26307):在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):在android.database.sqlite.SQLiteQuery。(SQLiteQuer y.java:49)10-14 14:54:50.429:ERROR / DatabaseUtils(26307):在android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)10-14 14:54:50.429:ERROR / DatabaseUtils(26307):在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):在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):在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):关闭VM 10-14 14:54:50.429:WARN / dalvikvm(27470):threadid = 1:线程退出时未捕获异常(组= 0x40015560) 10-14 14:54:50.433:ERROR / AndroidRuntime(27470):致命异常:主10-14 14:54:50.433:ERROR / AndroidRuntime(27470):android.database.sqlite.SQLiteException:near“*”:syntax错误:,在编译时: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):在android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330)10-14 14:54:50.433:ERROR / AndroidRuntime(27470):在android.content.ContentProviderProxy.query (ContentPro viderNative.java:366)10-14 14:54:50.433:ERROR / AndroidRuntime(27470):在android.content.ContentResolver.query(ContentResolver.java:262)
Can anyone help me.
谁能帮我。
1 个解决方案
#1
6
Try using it like:
尝试使用它像:
Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " ='" + number+"'", null,Calls.DEFAULT_SORT_ORDER);
#1
6
Try using it like:
尝试使用它像:
Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " ='" + number+"'", null,Calls.DEFAULT_SORT_ORDER);