gpt4 book ai didi

编译 : near "*": syntax error: , _id 时出现 android.database.sqlite.SQLiteException : SELECT calls.

转载 作者:行者123 更新时间:2023-11-29 14:55:33 25 4
gpt4 key购买 nike

我想从手机查询通话记录详情,我的查询如下

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)

谁能帮帮我。

最佳答案

尝试像这样使用它:

Cursor groupCur = mcontext.getContentResolver().query(Calls.CONTENT_URI,
CallLogAdapter.PROJECTION, Calls.NUMBER + " ='" + number+"'", null,Calls.DEFAULT_SORT_ORDER);

关于编译 : near "*": syntax error: , _id 时出现 android.database.sqlite.SQLiteException : SELECT calls.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7765760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com