title: Android's SimpleCursorAdapter with queries using DISTINCT
body: <p>Here's an interesting question that I'm shocked hasn't been asked more often on the internet.  Android's CursorAdapters are extremely useful once you get a ContentProvider up and running and learn how to use it, but they are limited due to their requirement on having the _id field as part of their query (an error is thrown without it).  Here's why:</p>
  
  <p>My specific problem is that I have two spinners:  One spinner should contain unique "category" names from the database, and the other should populate with all the database entries from the selected "category" (category being the column name, here).  This seems like a pretty simple setup that many programs might use, no?  Trying to implement that first spinner is where I've run into problems.</p>
  
  <p>Here's the query that I would like for that first spinner:</p>
  
  <pre><code>SELECT DISTINCT category FROM table;
  </code></pre>
  
  <p>Making this query throws an error on CursorAdapter because the _id column is required as part of the query.  Adding the _id column to the projection naturally returns every row of the table, since you're now asking for distinct id's as well, and every id is distinct (by definition).  Obviously I would rather see only one entry per category name.  </p>
  
  <p>I've already implemented a work around, which is to simply make the query above and then copy the results into an ArrayAdapter.  My reason for this post is to see if there was a more elegant solution to this odd little problem and start a discussion on what I could be doing better.  Alternate implementation suggestions, such as using different kinds of controls or adapters, are very welcome.  </p>