I am trying to get the top contacted call log details in android. Say if the person A has been contacted for 5 times, B has been contacted for 3 times and C 10 times. Now, I want to extract C and A as my top contacted persons in my phone.
Can any body explain me how to do this. I am able to get most recent call logs now.
I referred this, but no luck
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.
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 theContactManager
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.