0

Is there a way to determine which contact records has been modified or added to AddressBook.sqlitedb on IPhone. I mean I want my application to read the AddressBook.sqlitedb and determine which contact records has been added or modified to the AddressBook.sqlitedb from the time I last read the database? Do they maintain some kind of time stamp field in each table which stores the add or change time of a record?

Basically my problem is that when my application is not running the user can add/modify contacts on his Iphone. Now when my application launches how will it determine what changes have taken place? I donot want to store local copy of AddressBook.sqlitedb in my application and compare it with the Iphones original AddressBook.sqlitedb. There must be some smarter option to accomplish it. Please help guys.

khalid
  • 1
  • 1

2 Answers2

2

yes, there is a time stamp for adding or modifying.

the properties are:

NSString * const kABCreationDateProperty;
NSString * const kABModificationDateProperty;

but a better way is to use ABAddressBookRegisterExternalChangeCallback.

void ABAddressBookRegisterExternalChangeCallback (
   ABAddressBookRef addressBook,
   ABExternalChangeCallback callback,
   void *context
);

you can find more deatails here:

http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABAddressBookRef_iPhoneOS/Reference/reference.html

hope it hepls, shani

shannoga
  • 19,649
  • 20
  • 104
  • 169
0

You can't access the sqlite DB directly unless your iPhone is jailbroken, so that's out of the question. I would imagine (I'm not sure on this) that the ABRecordID returned by ABRecordGetRecordID() is valid long-term. To store a record of a contact, you can store the ABRecordID, then look up the properties for that contact when you need it. If you have more sophisticated needs (search/sort by properties for example), you'll have to implement that yourself somehow.

Nick Forge
  • 21,344
  • 7
  • 55
  • 78