获取java.lang.IllegalArgumentException:索引1处的绑定值为null

时间:2018-06-30 16:09:02

标签: android-sqlite

当我运行我的Android应用程序时。我收到以下错误:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.krish.contactmanager/com.example.krish.contactmanager.User.UserHomeActivity}: java.lang.IllegalArgumentException: the bind value at index 1 is null
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
                                                                                  at ......................

我对该查询的代码为:

    String[] projection =  {
            DBHelper.ContactEntry.CONTACT_NAME,
            DBHelper.ContactEntry.CONTACT_COMPANY,
            DBHelper.ContactEntry.CONTACT_PHONE,
            DBHelper.ContactEntry.CONTACT_EMAIL,
            DBHelper.ContactEntry.CONTACT_WEBSITE,
            DBHelper.ContactEntry.CONTACT_ADDRESS,
            DBHelper.ContactEntry.CONTACT_STATE,
            DBHelper.ContactEntry.CONTACT_COUNTRY };

    String selection = DBHelper.ContactEntry.ADDED_BY +" = ?";
    String[] selectionargs = { userId };
    Cursor cursor = db.query(
                           DBHelper.ContactEntry.TABLE_NAME,
                           projection,
                           selection,
                           selectionargs,
                           null,null,
                           DBHelper.ContactEntry.CONTACT_NAME+" ASC");

    while(cursor.moveToNext()) {
          //
    }

错误指示线是光标游标= db.query ........

0 个答案:

没有答案