# CursorAdapter

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:cursoradapter:28.0.0-alpha1  
Summary:[Constants](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#constants)\|[Inherited Constants](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)  

# CursorAdapter

| 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


abstract
class
CursorAdapter
`  
`


``

extends `[BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html)`


``


implements

`[Filterable](https://developer.android.com/reference/android/widget/Filterable.html)`


`

|---|---|-----------------------------------------|
| java.lang.Object                              |||
| ↳ | [android.widget.BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html) ||
|   | ↳ | android.support.v4.widget.CursorAdapter |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)Known Direct Subclasses [ResourceCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/ResourceCursorAdapter) |------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| | [ResourceCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/ResourceCursorAdapter) | Static library support version of the framework's[ResourceCursorAdapter](https://developer.android.com/reference/android/widget/ResourceCursorAdapter.html). | |

|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)Known Indirect Subclasses [SimpleCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter) |--------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| | [SimpleCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter) | Static library support version of the framework's[SimpleCursorAdapter](https://developer.android.com/reference/android/widget/SimpleCursorAdapter.html). | ||

<br />

*** ** * ** ***

Static library support version of the framework's[CursorAdapter](https://developer.android.com/reference/android/widget/CursorAdapter.html). Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

## Summary

|                                                                                                                                                                                                                                                                                        ### Constants                                                                                                                                                                                                                                                                                         ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [FLAG_AUTO_REQUERY](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_AUTO_REQUERY) *This constant was deprecated in API level 22.1.0. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).* |
| `int` | [FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER) If set the adapter will register a content observer on the cursor and will call[onContentChanged()](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#onContentChanged())when a notification comes in.                                                                                                                                                                                                 |

|                                                                                                                                                             ### Inherited constants                                                                                                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From interface` android.widget.Adapter ` |-------|--------------------------------| | `int` | `IGNORE_ITEM_VIEW_TYPE` <br /> | | `int` | `NO_SELECTION` <br />          | |

|                                                                                                                                                                                                                                                                                                                                                                                                  ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CursorAdapter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#CursorAdapter(android.content.Context, android.database.Cursor))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` c) ` *This constructor was deprecated in API level 22.1.0. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).* |
| ` `[CursorAdapter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#CursorAdapter(android.content.Context, android.database.Cursor, boolean))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` c, boolean autoRequery) ` Constructor that allows control over auto-requery.                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[CursorAdapter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#CursorAdapter(android.content.Context, android.database.Cursor, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` c, int flags) ` Recommended constructor.                                                                                                                                                                                                                                                                                                                                                                                                                          |

|                                                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                                                       ||
|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                                                          | ` `[bindView](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#bindView(android.view.View, android.content.Context, android.database.Cursor))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, `[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor) ` Bind an existing view to the data pointed to by cursor                                           |
| ` void`                                                                                                   | ` `[changeCursor](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#changeCursor(android.database.Cursor))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor) ` Change the underlying cursor to a new cursor.                                                                                                                                                                                                                                                                  |
| ` CharSequence`                                                                                           | ` `[convertToString](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#convertToString(android.database.Cursor))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor) ` <br /> Converts the cursor into a CharSequence.                                                                                                                                                                                                                                                          |
| ` int`                                                                                                    | ` `[getCount](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getCount())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)                         | ` `[getCursor](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getCursor())`() ` Returns the cursor.                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[View](https://developer.android.com/reference/android/view/View.html)                                 | ` `[getDropDownView](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getDropDownView(int, android.view.View, android.view.ViewGroup))`(int position, `[View](https://developer.android.com/reference/android/view/View.html)` convertView, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` parent) `                                                                                                                                                                             |
| ` `[Filter](https://developer.android.com/reference/android/widget/Filter.html)                           | ` `[getFilter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getFilter())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` `[FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html) | ` `[getFilterQueryProvider](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getFilterQueryProvider())`() ` Returns the query filter provider used for filtering.                                                                                                                                                                                                                                                                                                                                                    |
| ` Object`                                                                                                 | ` `[getItem](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getItem(int))`(int position) `                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` long`                                                                                                   | ` `[getItemId](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getItemId(int))`(int position) `                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[View](https://developer.android.com/reference/android/view/View.html)                                 | ` `[getView](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getView(int, android.view.View, android.view.ViewGroup))`(int position, `[View](https://developer.android.com/reference/android/view/View.html)` convertView, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` parent) `                                                                                                                                                                                             |
| ` boolean`                                                                                                | ` `[hasStableIds](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#hasStableIds())`() `                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[View](https://developer.android.com/reference/android/view/View.html)                                 | ` `[newDropDownView](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#newDropDownView(android.content.Context, android.database.Cursor, android.view.ViewGroup))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` parent) ` Makes a new drop down view to hold the data pointed to by cursor. |
| ` abstract `[View](https://developer.android.com/reference/android/view/View.html)                        | ` `[newView](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#newView(android.content.Context, android.database.Cursor, android.view.ViewGroup))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` cursor, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` parent) ` Makes a new view to hold the data pointed to by cursor.                           |
| ` `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)                         | ` `[runQueryOnBackgroundThread](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence))`(CharSequence constraint) ` Runs a query with the specified constraint.                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                   | ` `[setFilterQueryProvider](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider))`(`[FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html)` filterQueryProvider) ` Sets the query filter provider used to filter the current Cursor.                                                                                                                                                                          |
| ` `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)                         | ` `[swapCursor](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#swapCursor(android.database.Cursor))`(`[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` newCursor) ` Swap in a new Cursor, returning the old Cursor.                                                                                                                                                                                                                                                                 |

|                                                                                                                                                                                                                                            ### Protected methods                                                                                                                                                                                                                                             ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[init](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#init(android.content.Context, android.database.Cursor, boolean))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)` c, boolean autoRequery) ` *This method was deprecated in API level 22.1.0. Don't use this, use the normal constructor. This will be removed in the future.* |
| ` void` | ` `[onContentChanged](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#onContentChanged())`() ` Called when the[ContentObserver](https://developer.android.com/reference/android/database/ContentObserver.html)on the cursor receives a change notification.                                                                                                                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From class` `[android.widget.BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html)` ` |---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean`                                                                | ` areAllItemsEnabled() `                                                                                                                                                                              | | ` CharSequence[]`                                                         | ` getAutofillOptions() `                                                                                                                                                                              | | ` `[View](https://developer.android.com/reference/android/view/View.html) | ` getDropDownView(int arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` arg2) ` | | ` int`                                                                    | ` getItemViewType(int arg0) `                                                                                                                                                                         | | ` int`                                                                    | ` getViewTypeCount() `                                                                                                                                                                                | | ` boolean`                                                                | ` hasStableIds() `                                                                                                                                                                                    | | ` boolean`                                                                | ` isEmpty() `                                                                                                                                                                                         | | ` boolean`                                                                | ` isEnabled(int arg0) `                                                                                                                                                                               | | ` void`                                                                   | ` notifyDataSetChanged() `                                                                                                                                                                            | | ` void`                                                                   | ` notifyDataSetInvalidated() `                                                                                                                                                                        | | ` void`                                                                   | ` registerDataSetObserver(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` arg0) `                                                                  | | ` void`                                                                   | ` setAutofillOptions(CharSequence... arg0) `                                                                                                                                                          | | ` void`                                                                   | ` unregisterDataSetObserver(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` arg0) `                                                                | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)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() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From interface` `[android.widget.ListAdapter](https://developer.android.com/reference/android/widget/ListAdapter.html)` ` |---------------------|--------------------------| | ` abstract boolean` | ` areAllItemsEnabled() ` | | ` abstract boolean` | ` isEnabled(int arg0) `  | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From interface` `[android.widget.SpinnerAdapter](https://developer.android.com/reference/android/widget/SpinnerAdapter.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[View](https://developer.android.com/reference/android/view/View.html) | ` getDropDownView(int arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` arg2) ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From interface` `[android.widget.Filterable](https://developer.android.com/reference/android/widget/Filterable.html)` ` |------------------------------------------------------------------------------------------|-----------------| | ` abstract `[Filter](https://developer.android.com/reference/android/widget/Filter.html) | ` getFilter() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#)From interface` `[android.widget.Adapter](https://developer.android.com/reference/android/widget/Adapter.html)` ` |------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default CharSequence[]`                                                          | ` getAutofillOptions() `                                                                                                                                                                      | | ` abstract int`                                                                    | ` getCount() `                                                                                                                                                                                | | ` abstract Object`                                                                 | ` getItem(int arg0) `                                                                                                                                                                         | | ` abstract long`                                                                   | ` getItemId(int arg0) `                                                                                                                                                                       | | ` abstract int`                                                                    | ` getItemViewType(int arg0) `                                                                                                                                                                 | | ` abstract `[View](https://developer.android.com/reference/android/view/View.html) | ` getView(int arg0, `[View](https://developer.android.com/reference/android/view/View.html)` arg1, `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` arg2) ` | | ` abstract int`                                                                    | ` getViewTypeCount() `                                                                                                                                                                        | | ` abstract boolean`                                                                | ` hasStableIds() `                                                                                                                                                                            | | ` abstract boolean`                                                                | ` isEmpty() `                                                                                                                                                                                 | | ` abstract void`                                                                   | ` registerDataSetObserver(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` arg0) `                                                          | | ` abstract void`                                                                   | ` unregisterDataSetObserver(`[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)` arg0) `                                                        | ||

## Constants

### FLAG_AUTO_REQUERY

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

```
int FLAG_AUTO_REQUERY
```

<br />

**This constant was deprecated in API level 22.1.0.**   
This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).

If set the adapter will call requery() on the cursor whenever a content change notification is delivered. Implies[FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER).

<br />

Constant Value: 1 (0x00000001)  

### FLAG_REGISTER_CONTENT_OBSERVER

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

```
int FLAG_REGISTER_CONTENT_OBSERVER
```

If set the adapter will register a content observer on the cursor and will call[onContentChanged()](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#onContentChanged())when a notification comes in. Be careful when using this flag: you will need to unset the current Cursor from the adapter to avoid leaks due to its registered observers. This flag is not needed when using a CursorAdapter with a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).

<br />

Constant Value: 2 (0x00000002)

## Public constructors

### CursorAdapter

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

```
CursorAdapter (Context context, 
                Cursor c)
```

<br />

**This constructor was deprecated in API level 22.1.0.**   
This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor responsiveness or even Application Not Responding errors. As an alternative, use[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).

Constructor that always enables auto-requery.

<br />

|                             Parameters                             ||
|-----------|---------------------------------------------------------|
| `context` | `Context`: The context <br />                           |
| `c`       | `Cursor`: The cursor from which to get the data. <br /> |

### CursorAdapter

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

```
CursorAdapter (Context context, 
                Cursor c, 
                boolean autoRequery)
```

Constructor that allows control over auto-requery. It is recommended you not use this, but instead[CursorAdapter(Context, Cursor, int)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#CursorAdapter(android.content.Context, android.database.Cursor, int)). When using this constructor,[FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER)will always be set.

<br />

|                                                                                       Parameters                                                                                        ||
|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`     | `Context`: The context <br />                                                                                                                                            |
| `c`           | `Cursor`: The cursor from which to get the data. <br />                                                                                                                  |
| `autoRequery` | `boolean`: If true the adapter will call requery() on the cursor whenever it changes so the most recent data is always displayed. Using true here is discouraged. <br /> |

### CursorAdapter

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

```
CursorAdapter (Context context, 
                Cursor c, 
                int flags)
```

Recommended constructor.

<br />

|                                                                                                                                                                                    Parameters                                                                                                                                                                                     ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context` | `Context`: The context <br />                                                                                                                                                                                                                                                                                                                                          |
| `c`       | `Cursor`: The cursor from which to get the data. <br />                                                                                                                                                                                                                                                                                                                |
| `flags`   | `int`: Flags used to determine the behavior of the adapter; may be any combination of[FLAG_AUTO_REQUERY](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_AUTO_REQUERY)and[FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER). <br /> |

## Public methods

### bindView

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

```
void bindView (View view, 
                Context context, 
                Cursor cursor)
```

Bind an existing view to the data pointed to by cursor

<br />

|                                                       Parameters                                                        ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `view`    | `View`: Existing view, returned earlier by newView <br />                                                    |
| `context` | `Context`: Interface to application's global information <br />                                              |
| `cursor`  | `Cursor`: The cursor from which to get the data. The cursor is already moved to the correct position. <br /> |

### changeCursor

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

```
void changeCursor (Cursor cursor)
```

Change the underlying cursor to a new cursor. If there is an existing cursor it will be closed.

<br />

|                      Parameters                      ||
|----------|--------------------------------------------|
| `cursor` | `Cursor`: The new cursor to be used <br /> |

### convertToString

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

```
CharSequence convertToString (Cursor cursor)
```

<br />

Converts the cursor into a CharSequence. Subclasses should override this method to convert their results. The default implementation returns an empty String for null values or the default String representation of the value.

<br />

<br />

|                             Parameters                             ||
|----------|----------------------------------------------------------|
| `cursor` | `Cursor`: the cursor to convert to a CharSequence <br /> |

|                           Returns                            ||
|----------------|----------------------------------------------|
| `CharSequence` | a CharSequence representing the value <br /> |

### getCount

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

```
int getCount ()
```

<br />

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getCount()](https://developer.android.com/https://developer.android.com/reference/android/widget/Adapter#getCount())  

### getCursor

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

```
Cursor getCursor ()
```

Returns the cursor.

<br />

|                                              Returns                                               ||
|--------------------------------------------------------------------------------|--------------------|
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html) | the cursor. <br /> |

### getDropDownView

```
View getDropDownView (int position, 
                View convertView, 
                ViewGroup parent)
```

<br />

<br />

|            Parameters             ||
|---------------|--------------------|
| `position`    | `int` <br />       |
| `convertView` | `View` <br />      |
| `parent`      | `ViewGroup` <br /> |

|                                    Returns                                     ||
|------------------------------------------------------------------------|--------|
| [View](https://developer.android.com/reference/android/view/View.html) | <br /> |

### getFilter

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

```
Filter getFilter ()
```

<br />

<br />

|                                       Returns                                        ||
|------------------------------------------------------------------------------|--------|
| [Filter](https://developer.android.com/reference/android/widget/Filter.html) | <br /> |

### getFilterQueryProvider

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

```
FilterQueryProvider getFilterQueryProvider ()
```

Returns the query filter provider used for filtering. When the provider is null, no filtering occurs.

<br />

|                                                                                    Returns                                                                                    ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html) | the current filter query provider or null if it does not exist <br /> |

**See also:**

- [setFilterQueryProvider(android.widget.FilterQueryProvider)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider))
- [runQueryOnBackgroundThread(CharSequence)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence))  

### getItem

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

```
Object getItem (int position)
```

<br />

<br />

|        Parameters        ||
|------------|--------------|
| `position` | `int` <br /> |

|     Returns      ||
|----------|--------|
| `Object` | <br /> |

**See also:**

- [getItem(int)](https://developer.android.com/https://developer.android.com/reference/android/widget/Adapter#getItem(int))  

### getItemId

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

```
long getItemId (int position)
```

<br />

<br />

|        Parameters        ||
|------------|--------------|
| `position` | `int` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

**See also:**

- [getItemId(int)](https://developer.android.com/https://developer.android.com/reference/android/widget/Adapter#getItemId(int))  

### getView

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

```
View getView (int position, 
                View convertView, 
                ViewGroup parent)
```

<br />

<br />

|            Parameters             ||
|---------------|--------------------|
| `position`    | `int` <br />       |
| `convertView` | `View` <br />      |
| `parent`      | `ViewGroup` <br /> |

|                                    Returns                                     ||
|------------------------------------------------------------------------|--------|
| [View](https://developer.android.com/reference/android/view/View.html) | <br /> |

**See also:**

- [getView(int, View, ViewGroup)](https://developer.android.com/https://developer.android.com/reference/android/widget/Adapter#getView(int, android.view.View, android.view.ViewGroup))  

### hasStableIds

```
boolean hasStableIds ()
```

<br />

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### newDropDownView

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

```
View newDropDownView (Context context, 
                Cursor cursor, 
                ViewGroup parent)
```

Makes a new drop down view to hold the data pointed to by cursor.

<br />

|                                                       Parameters                                                        ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `context` | `Context`: Interface to application's global information <br />                                              |
| `cursor`  | `Cursor`: The cursor from which to get the data. The cursor is already moved to the correct position. <br /> |
| `parent`  | `ViewGroup`: The parent to which the new view is attached to <br />                                          |

|                                                Returns                                                 ||
|------------------------------------------------------------------------|--------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | the newly created view. <br /> |

### newView

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

```
View newView (Context context, 
                Cursor cursor, 
                ViewGroup parent)
```

Makes a new view to hold the data pointed to by cursor.

<br />

|                                                       Parameters                                                        ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `context` | `Context`: Interface to application's global information <br />                                              |
| `cursor`  | `Cursor`: The cursor from which to get the data. The cursor is already moved to the correct position. <br /> |
| `parent`  | `ViewGroup`: The parent to which the new view is attached to <br />                                          |

|                                                Returns                                                 ||
|------------------------------------------------------------------------|--------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | the newly created view. <br /> |

### runQueryOnBackgroundThread

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

```
Cursor runQueryOnBackgroundThread (CharSequence constraint)
```

Runs a query with the specified constraint. This query is requested by the filter attached to this adapter. The query is provided by a[FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html). If no provider is specified, the current cursor is not filtered and returned. After this method returns the resulting cursor is passed to[changeCursor(Cursor)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#changeCursor(android.database.Cursor))and the previous cursor is closed. This method is always executed on a background thread, not on the application's main thread (or UI thread.) Contract: when constraint is null or empty, the original results, prior to any filtering, must be returned.

<br />

|                                        Parameters                                         ||
|--------------|-----------------------------------------------------------------------------|
| `constraint` | `CharSequence`: the constraint with which the query must be filtered <br /> |

|                                                                  Returns                                                                  ||
|--------------------------------------------------------------------------------|-----------------------------------------------------------|
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html) | a Cursor representing the results of the new query <br /> |

**See also:**

- [getFilter()](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getFilter())
- [getFilterQueryProvider()](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getFilterQueryProvider())
- [setFilterQueryProvider(android.widget.FilterQueryProvider)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider))  

### setFilterQueryProvider

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

```
void setFilterQueryProvider (FilterQueryProvider filterQueryProvider)
```

Sets the query filter provider used to filter the current Cursor. The provider's[runQuery(CharSequence)](https://developer.android.com/reference/android/widget/FilterQueryProvider.html#runQuery(java.lang.CharSequence))method is invoked when filtering is requested by a client of this adapter.

<br />

|                                             Parameters                                              ||
|-----------------------|------------------------------------------------------------------------------|
| `filterQueryProvider` | `FilterQueryProvider`: the filter query provider or null to remove it <br /> |

**See also:**

- [getFilterQueryProvider()](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#getFilterQueryProvider())
- [runQueryOnBackgroundThread(CharSequence)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence))  

### swapCursor

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

```
Cursor swapCursor (Cursor newCursor)
```

Swap in a new Cursor, returning the old Cursor. Unlike[changeCursor(Cursor)](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter#changeCursor(android.database.Cursor)), the returned old Cursor is*not*closed.

<br />

|                        Parameters                        ||
|-------------|---------------------------------------------|
| `newCursor` | `Cursor`: The new cursor to be used. <br /> |

|                                                                                                                          Returns                                                                                                                          ||
|--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html) | Returns the previously set Cursor, or null if there was not one. If the given new Cursor is the same instance is the previously set Cursor, null is also returned. <br /> |

## Protected methods

### init

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

```
void init (Context context, 
                Cursor c, 
                boolean autoRequery)
```

<br />

**This method was deprecated in API level 22.1.0.**   
Don't use this, use the normal constructor. This will be removed in the future.

<br />

<br />

|           Parameters            ||
|---------------|------------------|
| `context`     | `Context` <br /> |
| `c`           | `Cursor` <br />  |
| `autoRequery` | `boolean` <br /> |

### onContentChanged

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

```
void onContentChanged ()
```

Called when the[ContentObserver](https://developer.android.com/reference/android/database/ContentObserver.html)on the cursor receives a change notification. The default implementation provides the auto-requery logic, but may be overridden by sub classes.

<br />

**See also:**

- [onChange(boolean)](https://developer.android.com/https://developer.android.com/reference/android/database/ContentObserver#onChange(boolean))  
-

  ## Interfaces

  - [DrawerLayout.DrawerListener](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.DrawerListener)
  - [NestedScrollView.OnScrollChangeListener](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.OnScrollChangeListener)
  - [SimpleCursorAdapter.CursorToStringConverter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter.CursorToStringConverter)
  - [SimpleCursorAdapter.ViewBinder](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter.ViewBinder)
  - [SlidingPaneLayout.PanelSlideListener](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.PanelSlideListener)
  - [SwipeRefreshLayout.OnChildScrollUpCallback](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.OnChildScrollUpCallback)
  - [SwipeRefreshLayout.OnRefreshListener](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.OnRefreshListener)
  - [TintableCompoundButton](https://developer.android.com/reference/android/support/v4/widget/TintableCompoundButton)
-

  ## Classes

  - [AutoScrollHelper](https://developer.android.com/reference/android/support/v4/widget/AutoScrollHelper)
  - [CircularProgressDrawable](https://developer.android.com/reference/android/support/v4/widget/CircularProgressDrawable)
  - [CompoundButtonCompat](https://developer.android.com/reference/android/support/v4/widget/CompoundButtonCompat)
  - [ContentLoadingProgressBar](https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar)
  - [CursorAdapter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter)
  - [DrawerLayout](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout)
  - [DrawerLayout.LayoutParams](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.LayoutParams)
  - [DrawerLayout.SavedState](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.SavedState)
  - [DrawerLayout.SimpleDrawerListener](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.SimpleDrawerListener)
  - [EdgeEffectCompat](https://developer.android.com/reference/android/support/v4/widget/EdgeEffectCompat)
  - [ExploreByTouchHelper](https://developer.android.com/reference/android/support/v4/widget/ExploreByTouchHelper)
  - [ImageViewCompat](https://developer.android.com/reference/android/support/v4/widget/ImageViewCompat)
  - [ListPopupWindowCompat](https://developer.android.com/reference/android/support/v4/widget/ListPopupWindowCompat)
  - [ListViewAutoScrollHelper](https://developer.android.com/reference/android/support/v4/widget/ListViewAutoScrollHelper)
  - [ListViewCompat](https://developer.android.com/reference/android/support/v4/widget/ListViewCompat)
  - [NestedScrollView](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView)
  - [PopupMenuCompat](https://developer.android.com/reference/android/support/v4/widget/PopupMenuCompat)
  - [PopupWindowCompat](https://developer.android.com/reference/android/support/v4/widget/PopupWindowCompat)
  - [ResourceCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/ResourceCursorAdapter)
  - [ScrollerCompat](https://developer.android.com/reference/android/support/v4/widget/ScrollerCompat)
  - [SimpleCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter)
  - [SlidingPaneLayout](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout)
  - [SlidingPaneLayout.LayoutParams](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.LayoutParams)
  - [SlidingPaneLayout.SimplePanelSlideListener](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.SimplePanelSlideListener)
  - [Space](https://developer.android.com/reference/android/support/v4/widget/Space)
  - [SwipeRefreshLayout](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout)
  - [TextViewCompat](https://developer.android.com/reference/android/support/v4/widget/TextViewCompat)
  - [ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper)
  - [ViewDragHelper.Callback](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback)