Question

Is it possible to create a custom ContentProvider to

  • Access android existing database (e.g. Contacts, SMS)?
  • Extend an Exciting ContentProvider which has access to android existing database (e.g. ContactsProvider to access Contacts DB)?

Thank you.

Was it helpful?

Solution

Short Answer: Yes

Longer answer:

ContentProviders are a layer sitting in between the "outside world" (e.g. other Android Activities) and the back-end data storage. You will never have direct access to the database. The database is stored in the Activities private storage space. So all you can do is dictated by the ContentProvider you are addressing.

If the ContentProvider only allows read-only access to the data, than that is all you can do.

So in the end, you can only offer access which has at most the kind of access as the ContentProvider you are using. You can however expose a different data structure. Or you could also create one ContentProvider which uses multiple other providers internally.

On the bottom line, within the given bounds, your imagination is the limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top