问题
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