以下代码将SIM卡中的联系人的电话号码返回为null。而对于Phone中的联系人,它会返回正确的值。请告诉我,URI是否应该与SIM读取电话号码不同。下面是我的代码,几乎是Android Contact教程的副本。
long contactId = -1;
// Load the display name for the specified person
Cursor cursor = contentResolver.query(contactUri,new String[]{Contacts._ID, Contacts.DISPLAY_NAME}, null, null, null);
try
{
if (cursor.moveToFirst())
{
contactId = cursor.getLong(0);
}
}
finally
{
cursor.close();
}
// Load the phone number (if any).
String phoneNumber=null;
cursor = contentResolver.query(Phone.CONTENT_URI,new String[]{Phone.NUMBER},Phone.CONTACT_ID + "=" + contactId, null, Phone.IS_SUPER_PRIMARY + " DESC");
try
{
if (cursor.moveToFirst())
{
phoneNumber=cursor.getString(0);
}
}
finally
{
cursor.close();
}