I have a simple Notes app which is similar in functionality to the Android NotePad sample. One addition is that every note can have Tags. A Note
can have several Tag
s and a Tag
can belong to several Note
s - thus making this a many-to-many relationship.
I have completed the DB Design using Foreign Keys and a Mapping Table. Now, I wish my app to plug into the Android Search Framework, which necessitates the use of a ContentProvider
to expose my data.
Are there any best practices to be followed for this scenario? I did find a few related questions on SO, but most of them dealt with one-to-many relationships (this one for example). I did conclude from these questions that it is best to have a single ContentProvider
per DB, and then use the Matcher concept to resolve multiple tables within the DB. That still leaves other questions open.
Given a
Note ID
, I would like to return all the tags associated with that Note. How do I go about setting up theContentUri
for such a case? Neither of"content://myexample/note/#"
and"content://myexample/tag/#"
would serve the purpose.None of the 6
ContentProvider
methods which I override would suit such a purpose, would they? I can of course, introduce a new method, but that would not be understood by the consumers of myContentProvider
.
Thanks in advance for your suggestions.
"content://myexample/note/tag/#"
. I am accepting this as an answer as it has helped me on my way. – Premillenarian