Getting newly inserted contacts in Android

好久不见. 提交于 2019-12-24 03:43:16

问题


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:


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.


来源:https://stackoverflow.com/questions/11281197/getting-newly-inserted-contacts-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!