0
在我的Android应用程序中,我想检索所有SIM卡和手机联系人。如果我单独执行代码,它可以正常工作,但如果我将它结合起来,我只需获得手机通讯录。如何获得两个联系? 我对SIM卡通讯录代码:以编程方式在Android中检索SIM卡联系人
private void SIMContacts()
{
try
{
String strPhonename = null;
String strphoneNo = null;
Uri simUri = Uri.parse("content://icc/adn");
Cursor cursorSim = this.getContentResolver().query(simUri,null,null,null,null);
while (cursorSim.moveToNext())
{
strPhonename =cursorSim.getString(cursorSim.getColumnIndex("name"));
strphoneNo = cursorSim.getString(cursorSim.getColumnIndex("number"));
strphoneNo.replaceAll("\\D","");
strphoneNo.replaceAll("&", "");
strPhonename=strPhonename.replace("|","");
Log.i("Contact: ", "name: "+strPhonename+" phone: "+strphoneNo);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
这给这只手机的联系人列表。我是能够检索但我希望将手机通讯录和SIM卡通讯录放在一起。 –