title: Android ContentProvider with Room
body: <p>I'm trying to use ContentProvider and Room. I try to learn from this sample: <a href="https://github.com/googlesamples/android-architecture-components/blob/master/PersistenceContentProviderSample/app/src/main/java/com/example/android/contentprovidersample/provider/SampleContentProvider.java" rel="nofollow noreferrer">here</a>. </p>
  
  <p>It allows to either get all cheeses or get cheese by id like this:</p>
  
  <pre><code>...
  CheeseDao cheese = SampleDatabase.getInstance(context).cheese();
  final Cursor cursor;
  if (code == CODE_CHEESE_DIR) {
     cursor = cheese.selectAll();
  } else {
     cursor = cheese.selectById(ContentUris.parseId(uri));
  }
  cursor.setNotificationUri(context.getContentResolver(), uri);
  return cursor;
  ...
  </code></pre>
  
  <p>I clearly don't understand much what is going on... There are two codes: CODE_CHEESE_DIR and CODE_CHEESE_ITEM that should probably somehow define what query will be made, but they are private and used like this:</p>
  
  <pre><code>final int code = MATCHER.match(uri);
  if (code == CODE_PLACE_DIR || code == CODE_PLACE_ITEM){
  ...
  </code></pre>
  
  <p>If I get it right, ContentProvider is somehow accessed through CursorLoader.</p>
  
  <pre><code>CursorLoader(getApplicationContext(),
               SampleContentProvider.URI_CHEESE,
               new String[]{Cheese.COLUMN_NAME},
               null, null, null);
  </code></pre>
  
  <p>I don't see where I specify what I want to select. How would I go about querying item by id? What if I needed a range of ids? </p>