Is it possible to delete contacts records using ABAddressBook?

nuzhatnuzhat Posts: 80Registered Users @
edited June 2011 in iOS SDK Development
hi all,
I know it is possible to access contacts records using ABAddressBook but I want to know is it possible to delete records using ABAddressBook?If yes then can anyone give me sample code for the same?
Post edited by nuzhat on


  • thomashwthomashw Posts: 327Registered Users
    edited October 2010
    Check out the ABAddressBookRemoveRecord function.

  • SundialSoftSundialSoft Posts: 302Registered Users @ @
    edited June 2011
    The code to remove a contact record programatically is as shown below.
    As far as I can see so far the address book framework's option to edit a contact record does not contain the delete button show at the bottom of the iphone address book app and I don't see a flag to turn it on. If this is possible & someone know how please post. I'm going to have another read of the docs myself to see.
    (I'm new to IOS development so apologies if my code has any errors/leaks. It works fine for me)

    ABAddressBookRef addressBook; 
    	CFErrorRef error = NULL; 
    	addressBook = ABAddressBookCreate(); //
        ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook,<YOUR 'PERSON' GOES HERE>);
        fullName.text = (NSString *)ABRecordCopyCompositeName((ABRecordRef)person);
        ABAddressBookRemoveRecord(addressBook, (ABRecordRef)person, &error );
        if(error !=NULL)
                  UIAlertView    *alert =[[UIAlertView alloc] initWithTitle:@";error" message:@";deleting" delegate:self cancelButtonTitle:@";cancel" otherButtonTitles:@";OK",nil];
            [alert show];
            [alert release];
        ABAddressBookSave(addressBook, NULL);
Sign In or Register to comment.

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!