public static final Uri ICC_CONTENT_URI = Uri.parse("content://icc/adn");
public static String _ID = BaseColumns._ID;
public static String NAME = "name";
public static String NUMBER = "number";
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(ICC_CONTENT_URI,null,null,null,null);
if (cursor!=null && cursor.getCount()>0){
final int colName = cursor.getColumnIndex(NAME);
final int colNumber = cursor.getColumnIndex(NUMBER);
while (cursor.moveToNext()){
String name = cursor.getString(colName);
String num = cursor.getString(colNumber);
if (num.equals(number.replace(" ","")) && !TextUtils.isEmpty(name)){
mNameFromSim = name;
mNumberForSim = context.getResources().getString(R.string.phone_label)+" "+number;
break;
}
}
}
}catch (Exception e){
e.printStackTrace();
if (cursor!=null){
cursor.close();
}
} finally {
if (cursor!=null){
cursor.close();
}
}
通过查询源码发现IccProvider.java 复杂simcard数据管理。
里面有关于sim卡联系人的数据操作