android-Contacts: Adding contacts

Source: Internet
Author: User

Add contact, use transaction public void Testaddcontact () {String name[]={"Jay Chou", "Nicholas Tse Feng", "Yan Cheng Xu", "JJ Lin", "Wilber Bai", "Ming Dao", "Donnie Yen", "zhouyumin",    "Show Luo", "May Days", "Andy Lau", "Mai June Long", "Cheng Long", "Su has Friends", "Life", "Du", "Kevin Cheng", "Wu Chun", "inflammation of the sub-Lun", "Guoshui", "Tangyvzhe", "Huddivan", "Wang Dongcheng"};               for (String ss:name) {//Insert null value First, then get rawcontactsid for interpolation below contentvalues values = new Contentvalues (); Insert a null value Uri Rawcontacturi = Getcontentresolver (). Insert (Rawcontacts.content_uri,va               Lues);                         Long Rawcontactsid = Contenturis.parseid (Rawcontacturi);               Insert name Values.clear () into the empty record just now;               A reference to the _id, this data belongs to Values.put (STRUCTUREDNAME.RAW_CONTACT_ID,RAWCONTACTSID); "Content_item_type" MIME TYPE used when storing the in data table Values.put (data.mimetype,s               Tructuredname.content_item_type);              The name that should is used to display of the contact. ValuEs.put (STRUCTUREDNAME.DISPLAY_NAME,SS);               Insert the real values Getcontentresolver (). Insert (data.content_uri,values);               Insert phone values.clear ();               Values.put (PHONE.RAW_CONTACT_ID,RAWCONTACTSID);  String "Data.mimetype": The MIME type of the item represented by this row//string "Content_item_type": MIME              Type used when storing the this in data table.               Values.put (Data.mimetype,phone.content_item_type);               Values.put (Phone.number, "1008611");       Getcontentresolver (). Insert (data.content_uri,values); }        }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.