Android How to read android Contacts and SIM Contacts?

拜拜、爱过 提交于 2019-12-12 03:39:12

问题


I am currently getting read only android contacts, below is the code I'm using:

String[] projecao = new String[] { Contacts._ID,
    Contacts.LOOKUP_KEY, Contacts.DISPLAY_NAME };
String selecao = Contacts.HAS_PHONE_NUMBER + " = 1";
Cursor contatos = contexto.getContentResolver().query(
    ContactsContract.Contacts.CONTENT_URI, projecao, selecao, null, null);

And to get Phone Number:

Cursor phones = contexto.getContentResolver().query(
                Phone.CONTENT_URI,
                new String[] { Phone.NUMBER },
                Phone.CONTACT_ID + " = ?",
                new String[] { contatos.getString(contatos
                        .getColumnIndex(Contacts._ID)) }, null);

I want to maintain a database of all contacts with numbers.

What I'm to do for get SIM card Contacts too?

Thank you for your time.


回答1:


To get phone contacts you can visit this link

and for sim contacts click here




回答2:


The Contacts you're reading are from the Contacts Provider, which is part of the Android platform. They're not read-only, although you should read the documentation before attempting to change them.

SIM card contacts are completely different. They're stored separately on the SIM card itself, and you probably have to use an app from the handset manufacturer or service provider to get to them. They have nothing to do with Google Contacts. I recommend against doing anything with them.



来源:https://stackoverflow.com/questions/13575286/android-how-to-read-android-contacts-and-sim-contacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!