I am trying to understand Android REST-style ContentProvider URIs. Assume that I have a database of messages, each of which has an "_id" and "recipient" field (among others).
I understand how to get all columns of all messages:
// Get all messages.
URI uri = Uri.parse("content://" + AUTHORITY + "/messages");
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
I understand how to get the message with an _id of 1:
// Get the message with _id 1.
URI uri = Uri.parse("content://" + AUTHORITY + "/messages/1");
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
What if I want to get the messages with a recipient value of foo@bar.com?
// Get the messages with recipient "foo@bar.com"
URI uri = Uri.parse("content://" + AUTHORITY + ??); // What goes here?
Cursor cursor = getContentResolver().query(uri, null,
"recipient = ?", "foo@bar.com", null);
I'd be happy to pass the recipient value in the URI if that's better style:
// Get the messages with recipient "foo@bar.com"/
URI uri = Uri.parse("content://" + AUTHORITY + ?? + "foo@bar.com"); // What goes here?
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
For this last use case, what is the preferred URI format?
Update: I am the author of both the ContentProvider and the client, so I can use whatever format I want. I would still like to know what's considered the best practice