2014-02-15 30 views
0

我是新來android.I'm開發一個程序,它在我有3種方法:如何在android中更新聯繫人信息?

1-FetchContactInformation() : read contacts id , name, number 
2-ChangeContactsInfo():change names and numbers 
3-UpdateContacts(): it shoulde read the list from second method and update each  contact one by one. 

我取聯繫人信息中此方法:

private ArrayList<ContactInfo> FetchContactInfo() { 
    int i = 0; 
    ArrayList<ContactInfo> contactList = new ArrayList<ContactInfo>(); 
    Cursor readingContactsCursor = getContentResolver().query(
      ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
      new String[] { Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER }, 
      null, null, Phone.DISPLAY_NAME + " ASC"); 

    contactList.clear(); 
    readingContactsCursor.moveToFirst(); 

    while (i < 3) { 
     ContactInfo contactInfo = new ContactInfo(); 
     contactInfo.setContactID(readingContactsCursor.getString(0) 
       .toString()); 
     contactInfo.setContactName(readingContactsCursor.getString(1) 
       .toString()); 
     contactInfo.setContactNumber(readingContactsCursor.getString(2) 
       .toString()); 
     readingContactsCursor.moveToNext(); 
     contactList.add(contactInfo); 


     i++; 
    } 
    readingContactsCursor.close(); 

    return contactList; 
} 

,但我不知道我應該使用哪些類和方法來更新聯繫人。 任何幫助真的很感激。 此致敬意。

回答

相關問題