Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Join query using Content Provider

How to join/compare query using content provider in android. Is this possible?

like image 693
Baskar Avatar asked Jan 15 '23 16:01

Baskar


1 Answers

Depending on the relation between the two tables, I usually apply any of the following solutions, which I document in the library project through which you would normally expose all your projects externally available interfaces (like a content provider):

  • If table A contains information that is hardly ever interesting without joining it with table B I simply always return the JOIN of A and B whenever querying A. You can document it in your library, at the place you will define the URI to "table A".

  • If table A and B contain data that should be query-able in isolation (what I mean is: without a JOIN) then I would normally provide an additional URI, for instance named A_JOIN_B_URI in my library, that, when queried, returns the JOIN of the two tables. Again, you document this in your lib.

There may be more options than this, but I think these adhere best to the notion of what a ContentProvider is: an interface that is agnostic about what data store is implemented behind it. Everywhere you explicitly use capabilities of the underlying data store, this is now made clear by the weird-looking "helper URI".

Any comments on this are welcome, maybe I could learn a thing or two..

like image 109
baske Avatar answered Jan 18 '23 07:01

baske