我想从手机查询通话记录详细信息,我的查询如下
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返回:错误代码= 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日期DESC 10-14 14:54:50.429:ERROR / DatabaseUtils(26307):在android.database.sqlite.SQLiteCompiledSql.native_compile(Native方法) 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):在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:83) 10-14 14:54:50.429:ERROR / DatabaseUtils(26307):在android.database.sqlite.SQLiteQuery。(SQLiteQuery.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):在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):在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“*”:语法错误:,同时编译:SELECT _id,number,name,date,duration,new,type FROM调用WHERE(number = * 674088888)ORDER BY日期DESC 10-14 14:54:50.433:ERROR / AndroidRuntime(27470):在android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158) 10-14 14:54:50.433:ERROR / AndroidRuntime(27470):在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(ContentProviderNative.java:366) 10-14 14:54:50.433:ERROR / AndroidRuntime(27470):在android.content.ContentResolver.query(ContentResolver.java:262)
任何人都可以帮助我。
答案 0 :(得分:6)
尝试使用它:
Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " ='" + number+"'", null,Calls.DEFAULT_SORT_ORDER);