Android内容提供商查询在应为false时返回true

Android内容提供商查询在应为false时返回true,android,sqlite,Android,Sqlite,我是android开发的新手,我正在尝试使用content provider插入表中,然后检查表并检索记录(如果存在)。它继续说它存在,但它不是我搜索的记录 Cursor c = contentResolver.query(ContentDescriptor.Survey.CONTENT_URI, projection, ContentDescriptor.Survey.Cols.SURVEYNAME + " =?", new Strin

我是android开发的新手,我正在尝试使用content provider插入表中,然后检查表并检索记录(如果存在)。它继续说它存在,但它不是我搜索的记录

            Cursor c = contentResolver.query(ContentDescriptor.Survey.CONTENT_URI, projection, 
                ContentDescriptor.Survey.Cols.SURVEYNAME + " =?", new String[] {surveyName}, null);
        if((c != null) && (c.moveToFirst())){
            //-----------------------------------------------------------------------------------
            //what if it does exist do something here
            Toast.makeText(getBaseContext(), "Survey Already Exists " + surveyName, Toast.LENGTH_SHORT).show();
            Intent i = new Intent().setClass(CreateSurveyActivity.this, PickSurveyActivity.class);              
        }
        else{
            //does not exist in database
            survey = SurveyRepository.instance().createNewSurvey(context, surveyName);
            Log.i(TAG, "survey did not exist creating survey");
            SurveyRepository.instance().loadContent(context);
        }
        c.close();
    }

查询
方法中,您没有将所选内容放入所做的查询中

因此,
SURVEYNAME+“=?”
被忽略

您需要调用类似以下内容:

return builder.query(db, projection, selection, selectionArgs, null, null, sortOrder);

将参数传递到数据库。

发布您的contentProvider。我是否必须使用另一个URI和路径\u for \u id\u标记,或者使用相同的内容URI。我将returnbuilder语句添加到查询方法中。类在原始帖子编辑下发布。好的,我想我知道了。。代码仍在编写中,但我认为我应该能够以我想要的方式实现它。感谢您对njzk2的帮助