Getting newly inserted contacts in Android

2019-07-08 07:43发布

In my application, I'm extracting all the contacts and upload them to the server. But there's a problem. I know how to extract all the contacts, but is there any way to get the newest contacts?

For example: The first time I open the app, I upload all the contacts but the other times I don't want to upload all of them, just the newest.

Do you know any way to do it?

Thanks!

1条回答
时光不老,我们不散
2楼-- · 2019-07-08 08:22

If your contacts have some order (by ID, by Name), you can save the identifier of the last contact you saved and the next time just check to see if there is a contact with identifier bigger than the last one you saved.

For example:

  1. You save a list of contacts and the last saved contact ID (assuming they are ordered, if not then save the max) was 100.
  2. Next run, you check to see if you have any contact with ID > 100 and you save these, and again you save the last inserted ID.
查看更多
登录 后发表回答