我可以使用ContactsContract.Data.CONTENT_URI
从哪些来源获得数据。特别是,如果包含SIM卡联系人,我很感兴趣。
由于
答案 0 :(得分:2)
如果您想要使用Sim Card的所有联系人,请尝试以下代码:
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();
}
}