I was able to do something similar in a different approach. In the Contacts API, there is a field called ContactsContract.Contacts.TIMES_CONTACTED
which tells the number of times that contact has been contacted.
This approach is not related to the CallLogs API. User can clear the CallLogs, but not the times contacted.
- Check this link for developer notes on ContactsContract.Contacts.
- Check this link for an android library that I have created which can give you this implementation.ae-apps-library You would be looking for the class
ContactManager
. Once you fetch all the contacts, you need to sort based on the times contacted field to get your required list.
Edit: If you see the fetchAllContacts
method in the ContactManager
from the library, you can see how the data are read using the API. All you need to do would be to sort this list based on the timesContacted field by writing a Custom Comparator and sorting the list using that.