Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Edit:</strong> <em>Okay, so this doesn't actually solve the question asked, because eidylon is tied to an existing ContentProvider as mentioned in their question. However, this does cover how you do a JOIN if you own the ContentProvider source and API. So I'll leave it for those who want to know how to handle that case.</em></p> <hr> <p>This is easy! But unintuitive... :)</p> <pre><code>query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) </code></pre> <p>Okay, so what is URI? Typically, you have one URI per table.</p> <p><code>content://com.example.coolapp.contacts</code> serves data out of your <code>CONTACTS</code> table. <code>content://com.example.coolapp.groupmembers</code> serves data out of your <code>GROUPMEMBERSHIP</code> table.</p> <p>But URI is really just a string. Use it however you like. Make a block of code in your ContentProvider that responds to <code>content://com.example.coolapp.contacts_in_group</code>. Within that block of code in the ContentProvider, you can get raw access to your SQLite DB, unfettered by the limited <code>query()</code> data model. Feel free to use it!</p> <p>Define your selection fields however you like. They don't <em>have</em> to map to table column names -- map them how you need to, in order to get your parameters in.</p> <p>Define your projection how you need -- It may contain columns from both tables after the join.</p> <p>Bing, you're done. Google does this same model internally in their own code -- Go look at the Contacts provider API -- you see "bla.RawContact" and "bla.Contact" and etc as content URIs. Each serves data out of the same table in the DB -- the different URIs just provide different <em>views</em> of that same table!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload