title: Best practices for joining tables and notifying ContentObservers in Android ContentProvider
body: <p>I have a ContentProvider which handles all the data insertion and retrieval related to my application, I'm following the pattern suggested by Virgil Dobjanschi on Google I/O. I am using the first pattern.</p>
  
  <p>My problem is that I have a logical entity that was represented by multiple tables in the database.</p>
  
  <p>For example, I have an Articles table and an ArticleExtras table. Articles represents the article itself, while ArticleExtras represents addtional information about certain Article, like number of comments. </p>
  
  <p>I used CursorAdapter in the UI to display the Article title and the number of comments of that Article in one row of ListView.</p>
  
  <p>To implement that, I added a <code>left outer join ArticleExtras on</code> statement in my ContentProvider query method for Article table, in order for CursorAdapter to get ArticleExtras along with the Article itself.</p>
  
  <p>When new Articles are fetched from the web, I insert it into the database via ContentProvider, and then the CursorAdapter got notified and update the UI, this part worked as expected.</p>
  
  <p>But when I fetched the number of comments  (ArticleExtras), I want the same CursorAdapter, which is watching for changes in the <code>content://com.myapp.content/Articles</code>, to be notified, too, so I can update my row in the ListView.</p>
  
  <p>My current implementation is like this: After inserting ArticleExtras into the database, I start a new query to check if Articles table has any rows that is related to the ArticleExtras I just inserted. If so I'll make a new uri for that Article( for example: <code>content://com.myapp.cotent/Articles/123</code>), and call <code>getContext().getContentResolver().notifyChange(uri, null)</code>, so the corresponding CursorAdapter that is watching for changes of this Article will get notified.</p>
  
  <p>Is the approach correct, or is there any better way to implement what I want?</p>