1, when reading the address book once read, as little as possible to read all the attributes, especially when the list is displayed, will make your list loading speed becomes unbearable, it is recommended to load a small number of properties, and then load all the properties when the details.
2, when reading a class of attributes, it is recommended to use a cursor, and placed outside the loop, can significantly speed up, with projection (indicating the column to query, in the code below is Contactor_ion).
The sample code is as follows:
private static final string[] Contactor_ion = new string[]{contactscontract.commondatakinds.phone.contact_id, Contactscontract.contacts.display_name,contactscontract.commondatakinds.phone.number};
。。。
Cursor phones = null; Contentresolver CR = Getcontentresolver (); try {phones = Cr.query (ContactsContract.CommonDataKinds.Phone.CONTENT_URI, Contactor_ion, NULL, NULL, "Sort_key"), if (phones! = null) {final int contactidindex = Phones.getcolumnindex (contactscont Ract. CommonDataKinds.Phone.CONTACT_ID); final int displaynameindex = Phones.getcolumnindex ( ContactsContract.Contacts.DISPLAY_NAME); final int phoneindex = Phones.getcolumnindex ( ContactsContract.CommonDataKinds.Phone.NUMBER); String phonestring, Displaynamestring, Contactidstring;while (Phones.movetonext ()) {Linkmanform LinkManForm = new Linkmanform ();p honestring = phones.getstring (phoneindex);d isplaynamestring = phones.getstring (DisplayNameIndex); contactidstring = phones.getstring (Contactidindex);}} catch (Exception e) {log.e (TAG, E.getmessage ());} finally {if (phones! = null) Phones.close ();}
3, query the contact's department attribute is organization.title, not organzition.department, this is a pit.
Android Address Book read optimization acceleration