How can one inject the sqlite3 keyword DISTINCT into an Android ContentProvider's query?

I have an SQL statement that I can use to return distinct rows from my Android sqlite3 database and I would like to pass it through a ContentProvider's query.

For example:

select lastName from peopleTable where upper(lastName) like upper("%smith%");

needs to be

select DISTINCT lastName from peopleTable where upper(lastName) like upper("%smith%");

Is there a clean way to pass the extra keywords to the select statement?


This isn't what I would call a "Good Idea", but depending on the CP, you can modify your projection such that the first entry in the projection is "DISTINCT Column" instead of just "Column". This seems to work as long as the ContentProvider is backed by a database and no modifications are made to your projection. I will re-iterate though, that this may not be the best future-proof idea as this "feature" isn't documented and more a matter of how queries are put together with the SQLiteDatabase class. If you know how the ContentProvider was built, then you can tell up-front whether or not this will work.

Need Your Help

How do I diff 2 Perforce Client Specs

version-control perforce perforce-client-spec

I have two perforce clients (client-a, client-b) that each contain about 40 file specs. They are similar, but each client has several file specs that aren't included in the other. I would like to...

Unable to use navigator.geolocation due to 'Only secure origins are allowed'

javascript jquery google-chrome geolocation

There has been an error, in the console, since I made my website using navigator.geolocation.getCurrentPosition (below). I realised this was going to cause a problem at some point in the future, an...