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

时间:2010-12-31 20:04:35

标签: android database sqlite android-contentprovider

有人知道这意味着什么吗?

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)

3 个答案:

答案 0 :(得分:179)

The bind value显然是指selectionArgs作为选择,您插入query()。如果此selectionArgs值为null,则可以获得此值。

答案 1 :(得分:2)

@Gray@pjv响应是了解导致此错误的问题的重点。您必须小心选择和selectionArgs匹配,如果您通过selection = nullselectionArgs = something,您也会收到此错误! :)笨蛋!

答案 2 :(得分:0)

这与问题不完全相关,但是我面临argument containted a dash (-) at the beginning的类似问题。这就是问题所在。

所以我逃避了这样的争论

return mDatabase.query(table_name,
                       null,
                       column_name + "=?",
                       new String[]{"\\" + argument},
                       null,
                       null,
                       null);

这为我解决了。

您还可以看到以下内容:How to escape special characters like ' in sqlite in android