How to determine the changes in device contacts in phonegap

I have an application which sync contacts from device contact manager and i have done it successfully now i want to synchronize the contacts which has been modified in my device contact manager to my app.

I didn’t find any plugin for this to get the information of contacts which has been modified,updated or added contact so that i can sync that particular contact in my app.

The worst scenario is to again fetch all contacts and compare each contacts and their fields for any changes.

Please suggest some good solution so that i can implement it.

Thanks

What you could look into is using an app.manifest. This way, you can store the data locally, then when the app boots up, it will check to see if there are any changes in the original data. If there isn’t use whats stored locally. If theres change, download a new copy and store it.

http://diveintohtml5.info/offline.html

@mhartington thanks for your useful info but the problem which i am facing is like i am not able to fetch the changes happened in my phonebook contacts to my app.

How can i determine which contacts has been modified or newly added or deleted. Any approach which i can follow for this solution.

Thanks

Ahh so your fetching the data from the native contact app.

Hmmm, I guess you’d just follow the same approach. Fetch the data, store it in localstorage, then everytime you start the app, fetch the data and compare it. If there are any changes, update what you have in local storage.

Not sure what your using the fetch the data from the device, so this would have to be adjusted.

yeah @mhartington you got it right i did it in same way but the problem is in order to identify the changes i need to again fetch all the contacts and have to make comparisons so this is not good approach that i ahve to iterate each contact with all my contacts.

So instead of again fetching all contacts is there any way we can fetch only those contacts that has been modified or newly added. so that i could simplify my approach.

Thanks

Off the top of my head, I can’t think of any.

Since the app will only know of the data it has stored, there’s no way to know ahead of time what the differences would be. Because the contact app doesn’t push the contacts to a data base where we can see the changes. So the only option would be fetch the contacts and compare.

Make sense?

Hi , If you get any solution please send me. I am also looking for something like that.