我收到此错误java.lang.IllegalArgumentException: Invalid column data1
这是我的代码
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data){
super.onActivityResult(reqCode, resultCode, data);
setResult(RESULT_OK, data);
switch (reqCode) {
case (PICK_CONTACT) :
if (resultCode == Activity.RESULT_OK) {
TextView phoneTextView = (TextView)findViewById(R.id.textView);
Uri contactData = data.getData();
String[] mProjection =
{
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER, // Contract class constant for the word column name
ContactsContract.CommonDataKinds.Phone._ID, // Contract class constant for the locale column name
};
Cursor c = getContentResolver().query(contactData,mProjection, null, null, null);
String contactName = "";
for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
contactName = c.getString(0);
Log.v("NAME OF CONTACT", contactName);
}
c.close();
}
}
//break;
}
}
当代码如上所示时,我收到了之前显示的错误消息。
然而,当我改变这段代码时
String[] mProjection =
{
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER, // Contract class constant for the word column name
ContactsContract.CommonDataKinds.Phone._ID, // Contract class constant for the locale column name
};
到
String[] mProjection =
{
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
};
可行,Log显示名称。
我的问题是,为什么会这样做?