Getting all contacts timestamp wise

£可爱£侵袭症+ 提交于 2019-12-11 05:25:41

问题


I have been trying to get all contacts of device sorted by the order they were added. I am using following query:

Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    String[] projection = new String[] {
            ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.NUMBER,
            ContactsContract.CommonDataKinds.Phone.CONTACT_STATUS_TIMESTAMP };

    Cursor c = getContentResolver().query(uri, projection, null, null,
            ContactsContract.CommonDataKinds.Phone.CONTACT_STATUS_TIMESTAMP);

It is not making any difference whether I am passing null or ContactsContract.CommonDataKinds.Phone.CONTACT_STATUS_TIMESTAMP in the sort order of the query

After inspection, the cursor has null in all timestamp columns. Is there a way to get this done or what I am doing wrong in this?


回答1:


That is the timestamp for the status update for the contact. You are getting null probably because none of the contacts have status updates.

Because of how contacts are aggregated, i don't think there is a way to find out which contact was added first because a contact's ID can actually change and appear to be added later than it originally was. Why do you want to figure this information out?



来源:https://stackoverflow.com/questions/8913425/getting-all-contacts-timestamp-wise

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