# ContentResolverCompat

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat#)  

# ContentResolverCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
ContentResolverCompat
`  
`

extends Object


``


`

|---|--------------------------------------------------|
| java.lang.Object                                    ||
| ↳ | android.support.v4.content.ContentResolverCompat |

<br />

*** ** * ** ***

Helper for accessing features in[ContentResolver](https://developer.android.com/reference/android/content/ContentResolver.html)in a backwards compatible fashion.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[Cursor](https://developer.android.com/reference/android/database/Cursor.html) | ` `[query](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat#query(android.content.ContentResolver, android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String, android.support.v4.os.CancellationSignal))`(`[ContentResolver](https://developer.android.com/reference/android/content/ContentResolver.html)` resolver, `[Uri](https://developer.android.com/reference/android/net/Uri.html)` uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, `[CancellationSignal](https://developer.android.com/reference/android/support/v4/os/CancellationSignal)` cancellationSignal) ` Query the given URI, returning a[Cursor](https://developer.android.com/reference/android/database/Cursor.html)over the result set with optional support for cancellation. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### query

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Cursor query (ContentResolver resolver, 
                Uri uri, 
                String[] projection, 
                String selection, 
                String[] selectionArgs, 
                String sortOrder, 
                CancellationSignal cancellationSignal)
```

Query the given URI, returning a[Cursor](https://developer.android.com/reference/android/database/Cursor.html)over the result set with optional support for cancellation.

For best performance, the caller should 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 the`selection`parameter, so that queries that differ only by those values will be recognized as the same for caching purposes.

<br />

<br />

<br />

|                                                                                                                                                      Parameters                                                                                                                                                      ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolver`           | `ContentResolver` <br />                                                                                                                                                                                                                                                                       |
| `uri`                | `Uri`: The URI, using the content:// scheme, for the content to retrieve. <br />                                                                                                                                                                                                               |
| `projection`         | `String`: A list of which columns to return. Passing null will return all columns, which is inefficient. <br />                                                                                                                                                                                |
| `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. <br />                                                                                                                  |
| `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. <br />                                                                                                |
| `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. <br />                                                                                                             |
| `cancellationSignal` | `CancellationSignal`: A signal to cancel the operation in progress, or null if none. If the operation is canceled, then[OperationCanceledException](https://developer.android.com/reference/android/support/v4/os/OperationCanceledException)will be thrown when the query is executed. <br /> |

|                                                                           Returns                                                                           ||
|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html) | A Cursor object, which is positioned before the first entry, or null <br /> |

**See also:**

- [Cursor](https://developer.android.com/https://developer.android.com/reference/android/database/Cursor)  
-

  ## Interfaces

  - [Loader.OnLoadCanceledListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCanceledListener)
  - [Loader.OnLoadCompleteListener](https://developer.android.com/reference/android/support/v4/content/Loader.OnLoadCompleteListener)
-

  ## Classes

  - [AsyncTaskLoader](https://developer.android.com/reference/android/support/v4/content/AsyncTaskLoader)
  - [ContentResolverCompat](https://developer.android.com/reference/android/support/v4/content/ContentResolverCompat)
  - [ContextCompat](https://developer.android.com/reference/android/support/v4/content/ContextCompat)
  - [CursorLoader](https://developer.android.com/reference/android/support/v4/content/CursorLoader)
  - [FileProvider](https://developer.android.com/reference/android/support/v4/content/FileProvider)
  - [IntentCompat](https://developer.android.com/reference/android/support/v4/content/IntentCompat)
  - [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)
  - [Loader.ForceLoadContentObserver](https://developer.android.com/reference/android/support/v4/content/Loader.ForceLoadContentObserver)
  - [LocalBroadcastManager](https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager)
  - [MimeTypeFilter](https://developer.android.com/reference/android/support/v4/content/MimeTypeFilter)
  - [PermissionChecker](https://developer.android.com/reference/android/support/v4/content/PermissionChecker)
  - [SharedPreferencesCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat)
  - [SharedPreferencesCompat.EditorCompat](https://developer.android.com/reference/android/support/v4/content/SharedPreferencesCompat.EditorCompat)
  - [WakefulBroadcastReceiver](https://developer.android.com/reference/android/support/v4/content/WakefulBroadcastReceiver)