Search code examples
androidandroid-contentprovider

How to evaluate efficiency of ContentProviders in Android?


I have few questions related to Android framework that I couldn't find either on android developer's site or somewhere else. So, I'm tempted to ask here.

I was asked these question's in an interview that:

How will you evaluate the efficiency of ContentProviders in Android ?

How much time does it take if you want to fetch 3000 Contacts ? Will it take same time if you want to fetch email's of the contacts as well?


Solution

  • First question

    How much time does it take if you want to fetch 3000 Contacts ?

    -> Depends on the device speed, anyway the time complexity is linear in input size: O(n)

    Second question

    Will it take same time if you want to fetch email's of the contacts as well?

    -> AFAIK The emails of the contacts are in the data table, a sub section of raw contact, and each contact could have more than one email, so probably you need more time to get all emails of all contacts compared to get only the contacts.

    The Contacts Provider is an Android content provider component. It maintains three types of data about a person, each of which corresponds to a table offered by the provider, as illustrated in

    enter image description here

    More details HERE