Public final cursor
Query (URI Uri,
String [] projection, string selection,
String [] selectionargs, string sortorder)
Since: API Level 1
Query the given Uri, returningCursor
Over the result set.
For best performance, the caller shocould follow these guidelines:
- Provide an explicit projection, to prevent reading data from storage that aren't going to be used.
- Use question mark parameter markers such as 'phone =? 'Instead of explicit values in
selection
Parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.
Parameters
Uri |
The URI, using the content: // scheme, for the content to retrieve. |
Projection |
A list of which columns to return. Passing null will return all columns, which is inefficient. |
Selection |
A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the where itself). Passing null will return all rows for the given Uri. |
Selectionargs |
You may include? S in selection, which will be replaced by the values from selectionargs, in the order that they appear in the selection. The values will be bound as strings. |
Sortorder |
How to order the rows, formatted as an SQL order by clause (excluding the order by itself). Passing null will use the default sort order, which may be unordered. |
Returns
- A cursor object, which is positioned before the first entry, or null
The above is written in API 2.2.
An SQL statement is as follows:
Select * From anytable where Var = 'const'
Anytable is Uri, * Is projection, and selection is "Var =? ", Selectionargs is written as follows: New String [] {'const '}
The last one is simple, that is, the sorting method.