我对 android 开发相当陌生,我正在尝试使用内容提供程序插入表中,然后检查表并检索记录(如果存在)。它继续说它存在但它不是我正在寻找的记录。
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();
}