Search code examples
androidandroid-contentproviderandroid-contactsandroid-contentresolverandroid-syncadapter

How to filter Contacts on CONTACT_LAST_UPDATED_TIMESTAMP while getting contacts from Phonebook Android?


In my application i want to get contact from phone and i want to filter it on CONTACT_LAST_UPDATED_TIMESTAMP please help me how can it possible?

my query is :

 Cursor crr = cr.query(
                        ContactsContract.CommonDataKinds.Phone.CONTENT_URI,                       
 new String[] {ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                ContactsContract.CommonDataKinds.Phone.CONTACT_LAST_UPDATED_TIMESTAMP,
                                ContactsContract.CommonDataKinds.Phone.DATA_VERSION,                                
                        ContactsContract.CommonDataKinds.Phone.CONTACT_LAST_UPDATED_TIMESTAMP + " = ?",
                        new String[]{" > '1455531760472' "}, null);

but this query return 0 raw count. please show me is it right way for filter or not?


Solution

  • I put my own question's answer :

    Cursor crr = cr.query(
                            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,                       
     new String[] {ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                    ContactsContract.CommonDataKinds.Phone.CONTACT_LAST_UPDATED_TIMESTAMP,
                                    ContactsContract.CommonDataKinds.Phone.DATA_VERSION,                                
                            ContactsContract.CommonDataKinds.Phone.CONTACT_LAST_UPDATED_TIMESTAMP + " > ?",
                            new String[]{"1455531760472"}, null);