Four Parameters of contentresolver query ()

Source: Internet
Author: User
Public final cursor
Query (URI Uri,
String [] projection, string selection,
String [] selectionargs, string sortorder)

Since: API Level 1

Query the given Uri, returningCursorOver 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
    selectionParameter, 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.