Share via


ContentResolver.Query Method

Definition

Overloads

Query(Uri, String[], Bundle, CancellationSignal)

Query the given URI, returning a Cursor over the result set with support for cancellation.

Query(Uri, String[], String, String[], String)

Query the given URI, returning a Cursor over the result set.

Query(Uri, String[], String, String[], String, CancellationSignal)

Query the given URI, returning a Cursor over the result set with optional support for cancellation.

Query(Uri, String[], Bundle, CancellationSignal)

Query the given URI, returning a Cursor over the result set with support for cancellation.

[Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/database/Cursor;", "", ApiSince=26)]
public Android.Database.ICursor? Query (Android.Net.Uri uri, string[]? projection, Android.OS.Bundle? queryArgs, Android.OS.CancellationSignal? cancellationSignal);
[<Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Landroid/os/Bundle;Landroid/os/CancellationSignal;)Landroid/database/Cursor;", "", ApiSince=26)>]
member this.Query : Android.Net.Uri * string[] * Android.OS.Bundle * Android.OS.CancellationSignal -> Android.Database.ICursor

Parameters

uri
Uri

The URI, using the content:// scheme, for the content to retrieve.

projection
String[]

A list of which columns to return. Passing null will return all columns, which is inefficient.

queryArgs
Bundle

A Bundle containing additional information necessary for the operation. Arguments may include SQL style arguments, such as ContentResolver#QUERY_ARG_SQL_LIMIT, but note that the documentation for each individual provider will indicate which arguments they support.

cancellationSignal
CancellationSignal

A signal to cancel the operation in progress, or null if none. If the operation is canceled, then OperationCanceledException will be thrown when the query is executed.

Returns

A Cursor object, which is positioned before the first entry. May return null if the underlying content provider returns null, or if it crashes.

Attributes

Remarks

Query the given URI, returning a Cursor over the result set with support for cancellation.

For best performance, the caller should follow these guidelines:

<li>Provide an explicit projection, to prevent reading data from storage that aren't going to be used.

Provider must identify which QUERY_ARG_SORT* arguments were honored during the preparation of the result set by including the respective argument keys in the Cursor extras Bundle. See #EXTRA_HONORED_ARGS for details.

Java documentation for android.content.ContentResolver.query(android.net.Uri, java.lang.String[], android.os.Bundle, android.os.CancellationSignal).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Query(Uri, String[], String, String[], String)

Query the given URI, returning a Cursor over the result set.

[Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", "")]
public Android.Database.ICursor? Query (Android.Net.Uri uri, string[]? projection, string? selection, string[]? selectionArgs, string? sortOrder);
[<Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", "")>]
member this.Query : Android.Net.Uri * string[] * string * string[] * string -> Android.Database.ICursor

Parameters

uri
Uri

The URI, using the content:// scheme, for the content to retrieve.

projection
String[]

A list of which columns to return. Passing null will return all columns, which is inefficient.

selection
String

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
String[]

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
String

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. May return null if the underlying content provider returns null, or if it crashes.

Attributes

Remarks

Query the given URI, returning a Cursor over the result set.

For best performance, the caller should follow these guidelines: <ul> <li>Provide an explicit projection, to prevent reading data from storage that aren't going to be used.</li> <li>Use question mark parameter markers such as 'phone=?' instead of explicit values in the selection parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.</li> </ul>

Java documentation for android.content.ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

Query(Uri, String[], String, String[], String, CancellationSignal)

Query the given URI, returning a Cursor over the result set with optional support for cancellation.

[Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/database/Cursor;", "")]
public Android.Database.ICursor? Query (Android.Net.Uri uri, string[]? projection, string? selection, string[]? selectionArgs, string? sortOrder, Android.OS.CancellationSignal? cancellationSignal);
[<Android.Runtime.Register("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Landroid/os/CancellationSignal;)Landroid/database/Cursor;", "")>]
member this.Query : Android.Net.Uri * string[] * string * string[] * string * Android.OS.CancellationSignal -> Android.Database.ICursor

Parameters

uri
Uri

The URI, using the content:// scheme, for the content to retrieve.

projection
String[]

A list of which columns to return. Passing null will return all columns, which is inefficient.

selection
String

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
String[]

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
String

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.

cancellationSignal
CancellationSignal

A signal to cancel the operation in progress, or null if none. If the operation is canceled, then OperationCanceledException will be thrown when the query is executed.

Returns

A Cursor object, which is positioned before the first entry. May return null if the underlying content provider returns null, or if it crashes.

Attributes

Remarks

Query the given URI, returning a Cursor over the result set with optional support for cancellation.

For best performance, the caller should follow these guidelines: <ul> <li>Provide an explicit projection, to prevent reading data from storage that aren't going to be used.</li> <li>Use question mark parameter markers such as 'phone=?' instead of explicit values in the selection parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.</li> </ul>

Java documentation for android.content.ContentResolver.query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String, android.os.CancellationSignal).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to