jstevenco
jstevenco

Reputation: 2953

Possible to write custom content provider for existing system database?

Not sure of the absolute utility of this but seems as though it should be possible and useful.

Can you extend ContentProvider to provide URIs representing new queries (i.e., joins across multiple tables not specified by existing URIs) for an existing system database?

The alternative seems to be that I need to write a series of cursor queries then join them -- seems like a lot of unnecessary code duplication.

I have been trying this for the contacts database as an exercise, but no love so far.

The crux seems to be that I cannot open a database in another package during the setup phase.

Am I just completely out in left field here?

It's possible as I am new to both Java and Android.

Comments and/or pointers to relevant resources are appreciated.

Thanks,

Steve

Upvotes: 0

Views: 682

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007359

Can you extend ContentProvider to provide URIs representing new queries (i.e., joins across multiple tables not specified by existing URIs) for an existing system database?

Not really, only because you don't have direct access to existing system databases, in terms of SQLite. Now, creating a ContentProvider that performs your joins for you, as a reusability measure, is certainly doable, though I would get worried about the performance overhead of multiple cross-process hops.

Upvotes: 1

Related Questions