IllegalArgumentException: the bind value at index 1 is null
Asked Answered
E

3

71

Does anybody know what this means?

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)
Enlace answered 31/12, 2010 at 20:4 Comment(1)
It means you have an illegal argument somewhere. Presumably you're passing null somewhere that it can't be null.Schnitzel
E
202

The bind value apparently refers to the selectionArgs for the selection, that you insert into query(). If such a selectionArgs value is null, you get this.

Enlace answered 31/12, 2010 at 21:1 Comment(3)
Umm, I appreciate this is an old post, but what if you want to search for NULL like I am trying to do here: #14175733Tripody
My issue was that the selection wasn't fully correct. I missed the ? so I had columnName instead of columnName +"=?".Erastianism
Something that wasn't immediately apparent to me: selectionArgs is an array, and if one the values is null, you'll get this error.Verbality
O
3

@Gray and @pjv response was the point for realize what problem caused this error. You have to be careful with selection and selectionArgs matching, if you pass selection = null and selectionArgs = something, you will get this error too! :) Thnks!

Orthotropous answered 20/9, 2013 at 10:9 Comment(0)
O
1

This does not exactly relate to the question, but I was facing a similiar issue for me the argument containted a dash (-) at the beginning. This was causing the issue.

So I escaped the argument like this

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

This solved it for me.

You can also see this : How to escape special characters like ' in sqlite in android

Orianna answered 11/7, 2020 at 3:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.