IllegalArgumentException:索引1处的绑定值为null

有人知道这是什么意思吗?

12-31 20:55:45.861: ERROR/AndroidRuntime(12478): Caused by: java.lang.IllegalArgumentException: the bind value at index 1 is null 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:234) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:182) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:330) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:280) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.providers.ProductContentProvider.query(ProductContentProvider.java:350) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.content.ContentProvider$Transport.query(ContentProvider.java:163) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.content.ContentResolver.query(ContentResolver.java:245) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.providers.FacadeContentProvider.query(FacadeContentProvider.java:563) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.content.ContentProvider$Transport.query(ContentProvider.java:163) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.content.ContentResolver.query(ContentResolver.java:245) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.util.ScanAddTask.existsProduct(ScanAddTask.java:164) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.util.ScanAddTask.<init>(ScanAddTask.java:71) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.util.ItemScanAddTask.<init>(ItemScanAddTask.java:34) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow$MusicCDItemScanAddTask.<init>(CDCollectionViewWindow.java:147) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow.restoreLocalState(CDCollectionViewWindow.java:1044) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow.onRestoreInstanceState(CDCollectionViewWindow.java:966) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.app.Activity.performRestoreInstanceState(Activity.java:815) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096) 12-31 20:55:45.861: ERROR/AndroidRuntime(12478): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2641) 

“绑定值”显然是指selectionArgs的select,你插入到query()。 如果这样的selArgs值为null,那么你会得到这个。

@Gray和@pjv响应是意识到什么问题导致了这个错误。 你必须小心select和selectionArgs匹配,如果你通过selection = null和selectionArgs = something,你也会得到这个错误! 🙂 Thnks!