Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>Uri</code> does not point to any table. It points to whatever you feel like pointing it to.</p> <p>Let's pretend that your two tables are <code>Customer</code> and <code>Order</code>. One customer may have many orders. You want to execute a query to get all outstanding orders... but you want to join in some customer-related columns that you will need, such as the customer's name.</p> <p>Let's further pretend that you already have <code>content://your.authority.goes.here/customer</code> and <code>content://your.authority.goes.here/order</code> defined to purely query those tables.</p> <p>You have two choices:</p> <ol> <li><p>Add the join of the customer's display name on your <code>/order</code> <code>Uri</code>. Having another available column probably will not break any existing consumers of the provider (though testing is always a good idea). This is what <code>ContactsContract</code> does -- it joins in some base columns, like the contact's name, on pretty much all queries of all tables.</p></li> <li><p>Create <code>content://your.authority.goes.here/orderWithCust</code> that does the same basic query as <code>/order</code> does, but contains your join. In this case, you could have <code>insert()</code>, <code>update()</code>, and <code>delete()</code> throw some sort of <code>RuntimeException</code>, to remind you that you should not be modifying data using <code>/orderWithCust</code> as a <code>Uri</code>.</p></li> </ol> <p>In the end, designing a <code>ContentProvider</code> <code>Uri</code> system is similar to designing a REST Web service's URL system. In both cases, the join has to be done on the provider/server side, and so you may need to break the one-table-to-one-URL baseline to offer up some useful joins.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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