# CursorAdapter

# CursorAdapter

Artifact:[androidx.cursoradapter:cursoradapter](https://developer.android.com/jetpack/androidx/releases/cursoradapter)  
[View Source](https://cs.android.com/search?q=file:androidx/cursoradapter/widget/CursorAdapter.java+class:androidx.cursoradapter.widget.CursorAdapter)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter "View this page in Java")

<br />

```
abstract class CursorAdapter : BaseAdapter, Filterable
```

<br />

|---|---|-------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                              |||
| ↳ | [android.widget.BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html)                                        ||
|   | ↳ | [androidx.cursoradapter.widget.CursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter) |

Known direct subclasses  
[ResourceCursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/ResourceCursorAdapter)  

|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ResourceCursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/ResourceCursorAdapter) | Static library support version of the framework's[android.widget.ResourceCursorAdapter](https://developer.android.com/reference/android/widget/ResourceCursorAdapter.html). |

Known indirect subclasses  
[SimpleCursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/SimpleCursorAdapter)  

|-------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SimpleCursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/SimpleCursorAdapter) | Static library support version of the framework's[android.widget.SimpleCursorAdapter](https://developer.android.com/reference/android/widget/SimpleCursorAdapter.html). |

*** ** * ** ***

Static library support version of the framework's[android.widget.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                                    |
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FLAG_AUTO_REQUERY](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#FLAG_AUTO_REQUERY())` = 1` **This property is deprecated.** 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. <br />                                    |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER())` = 2` If set the adapter will register a content observer on the cursor and will call[onContentChanged](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#onContentChanged())when a notification comes in. |

|                                                                                                                                                                                                                                                                                         ### Public constructors                                                                                                                                                                                                                                                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ~~[CursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor))~~`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` **This function is deprecated.** 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. <br /> |
| [CursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor,boolean))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!, autoRequery: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Constructor that allows control over auto-requery.                                                                           |
| [CursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor,int))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!, flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Recommended constructor.                                                                                                                       |

|                                           ### Public functions                                            |
|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                  | [bindView](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#bindView(android.view.View,android.content.Context,android.database.Cursor))`(view: `[View](https://developer.android.com/reference/android/view/View.html)`!, context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Bind an existing view to the data pointed to by cursor                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                             | [changeCursor](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#changeCursor(android.database.Cursor))`(cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Change the underlying cursor to a new cursor.                                                                                                                                                                                                                                                                    |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`         | [convertToString](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#convertToString(android.database.Cursor))`(cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Converts the cursor into a CharSequence.                                                                                                                                                                                                                                                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                               | [getCount](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getCount())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`                         | [getCursor](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getCursor())`()` Returns the cursor.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [View](https://developer.android.com/reference/android/view/View.html)`!`                                 | [getDropDownView](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getDropDownView(int,android.view.View,android.view.ViewGroup))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, convertView: `[View](https://developer.android.com/reference/android/view/View.html)`!, parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!)`                                                                                                    |
| [Filter](https://developer.android.com/reference/android/widget/Filter.html)`!`                           | [getFilter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getFilter())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html)`!` | [getFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getFilterQueryProvider())`()` Returns the query filter provider used for filtering.                                                                                                                                                                                                                                                                                                                                                        |
| [Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`!`                            | [getItem](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getItem(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)`                                                                                                                                                                                                                                                                                                                                                  |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                             | [getItemId](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getItemId(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)`                                                                                                                                                                                                                                                                                                                                              |
| [View](https://developer.android.com/reference/android/view/View.html)`!`                                 | [getView](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getView(int,android.view.View,android.view.ViewGroup))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, convertView: `[View](https://developer.android.com/reference/android/view/View.html)`!, parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!)`                                                                                                                    |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                       | [hasStableIds](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#hasStableIds())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [View](https://developer.android.com/reference/android/view/View.html)`!`                                 | [newDropDownView](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#newDropDownView(android.content.Context,android.database.Cursor,android.view.ViewGroup))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!, parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!)` 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/kotlin/androidx/cursoradapter/widget/CursorAdapter#newView(android.content.Context,android.database.Cursor,android.view.ViewGroup))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!, parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!)` 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/kotlin/androidx/cursoradapter/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence))`(constraint: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!)` Runs a query with the specified constraint.                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                             | [setFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider))`(filterQueryProvider: `[FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html)`!)` 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/kotlin/androidx/cursoradapter/widget/CursorAdapter#swapCursor(android.database.Cursor))`(newCursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Swap in a new Cursor, returning the old Cursor.                                                                                                                                                                                                                                                                   |

|                            ### Protected functions                            |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | ~~[init](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#init(android.content.Context,android.database.Cursor,boolean))~~`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!, autoRequery: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` **This function is deprecated.** Don't use this, use the normal constructor. <br /> |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onContentChanged](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#onContentChanged())`()` Called when the[ContentObserver](https://developer.android.com/reference/android/database/ContentObserver.html)on the cursor receives a change notification.                                                                                                                                                                                                                                                |

|                                                                                                                                                                                                                                                                                                                                                                       ### Inherited Constants                                                                                                                                                                                                                                                                                                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[android.widget.Adapter](https://developer.android.com/reference/android/widget/Adapter.html) |-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [IGNORE_ITEM_VIEW_TYPE](https://developer.android.com/reference/android/widget/Adapter.html#IGNORE_ITEM_VIEW_TYPE())` = -1` | | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [NO_SELECTION](https://developer.android.com/reference/android/widget/Adapter.html#NO_SELECTION())` = -2147483648`          | |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[android.widget.BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html) |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                   | [areAllItemsEnabled](https://developer.android.com/reference/android/widget/BaseAdapter.html#areAllItemsEnabled())`()`                                                                                                                                                                                                                        | | [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!>!` | [getAutofillOptions](https://developer.android.com/reference/android/widget/BaseAdapter.html#getAutofillOptions())`()`                                                                                                                                                                                                                        | | [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                           | [getItemViewType](https://developer.android.com/reference/android/widget/BaseAdapter.html#getItemViewType(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)`                                                                                                                                    | | [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                           | [getViewTypeCount](https://developer.android.com/reference/android/widget/BaseAdapter.html#getViewTypeCount())`()`                                                                                                                                                                                                                            | | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                   | [isEmpty](https://developer.android.com/reference/android/widget/BaseAdapter.html#isEmpty())`()`                                                                                                                                                                                                                                              | | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                   | [isEnabled](https://developer.android.com/reference/android/widget/BaseAdapter.html#isEnabled(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)`                                                                                                                                                | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                         | [notifyDataSetChanged](https://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged())`()`                                                                                                                                                                                                                    | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                         | [notifyDataSetInvalidated](https://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetInvalidated())`()`                                                                                                                                                                                                            | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                         | [registerDataSetObserver](https://developer.android.com/reference/android/widget/BaseAdapter.html#registerDataSetObserver(android.database.DataSetObserver))`(observer: `[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)`!)`                                                                 | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                         | [setAutofillOptions](https://developer.android.com/reference/android/widget/BaseAdapter.html#setAutofillOptions(java.lang.CharSequence...))`(options: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!>!)` | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                         | [unregisterDataSetObserver](https://developer.android.com/reference/android/widget/BaseAdapter.html#unregisterDataSetObserver(android.database.DataSetObserver))`(observer: `[DataSetObserver](https://developer.android.com/reference/android/database/DataSetObserver.html)`!)`                                                             | |

## Constants

### FLAG_AUTO_REQUERY

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  
Deprecated in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
const val FLAG_AUTO_REQUERY = 1: Int
```
| **This property is deprecated.**   
|
| 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[android.app.LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[android.content.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/kotlin/androidx/cursoradapter/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER()).  

### FLAG_REGISTER_CONTENT_OBSERVER

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
const val FLAG_REGISTER_CONTENT_OBSERVER = 2: Int
```

If set the adapter will register a content observer on the cursor and will call[onContentChanged](https://developer.android.com/reference/kotlin/androidx/cursoradapter/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[android.content.CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).  

## Public constructors

### CursorAdapter

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  
Deprecated in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
[CursorAdapter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor))(context: Context!, c: Cursor!)
```
| **This function is deprecated.**   
|
| 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[android.app.LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.html)with a[android.content.CursorLoader](https://developer.android.com/reference/android/content/CursorLoader.html).

Constructor that always enables auto-requery.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|----------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | The context                            |
| `c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`        | The cursor from which to get the data. |

### CursorAdapter

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
CursorAdapter(context: Context!, c: Cursor!, autoRequery: Boolean)
```

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

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!`      | The context                                                                                                                                            |
| `c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`             | The cursor from which to get the data.                                                                                                                 |
| `autoRequery: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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. |

### CursorAdapter

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
CursorAdapter(context: Context!, c: Cursor!, flags: Int)
```

Recommended constructor.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | The context                                                                                                                                                                                                                                                                                                                                                                        |
| `c: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`        | The cursor from which to get the data.                                                                                                                                                                                                                                                                                                                                             |
| `flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)          | Flags used to determine the behavior of the adapter; may be any combination of[FLAG_AUTO_REQUERY](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#FLAG_AUTO_REQUERY())and[FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER()). |

## Public functions

### bindView

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
abstract fun bindView(view: View!, context: Context!, cursor: Cursor!): Unit
```

Bind an existing view to the data pointed to by cursor  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| `view: `[View](https://developer.android.com/reference/android/view/View.html)`!`             | Existing view, returned earlier by newView                                                  |
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | Interface to application's global information                                               |
| `cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`   | The cursor from which to get the data. The cursor is already moved to the correct position. |

### changeCursor

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun changeCursor(cursor: Cursor!): Unit
```

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

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|---------------------------|
| `cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!` | The new cursor to be used |

### convertToString

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun convertToString(cursor: Cursor!): CharSequence!
```

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.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|-----------------------------------------|
| `cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!` | the cursor to convert to a CharSequence |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|---------------------------------------|
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!` | a CharSequence representing the value |

### getCount

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getCount(): Int
```  

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

### getCursor

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getCursor(): Cursor!
```

Returns the cursor.  

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

### getDropDownView

```
fun getDropDownView(position: Int, convertView: View!, parent: ViewGroup!): View!
```  

### getFilter

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getFilter(): Filter!
```  

### getFilterQueryProvider

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getFilterQueryProvider(): FilterQueryProvider!
```

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

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

|                                                                                    See also                                                                                     |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider)) |   |
| [runQueryOnBackgroundThread](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence))     |   |

### getItem

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getItem(position: Int): Any!
```  

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

### getItemId

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getItemId(position: Int): Long
```  

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

### getView

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun getView(position: Int, convertView: View!, parent: ViewGroup!): View!
```  

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

### hasStableIds

```
fun hasStableIds(): Boolean
```  

### newDropDownView

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

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

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

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | Interface to application's global information                                               |
| `cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`   | The cursor from which to get the data. The cursor is already moved to the correct position. |
| `parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!` | The parent to which the new view is attached to                                             |

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

### newView

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
abstract fun newView(context: Context!, cursor: Cursor!, parent: ViewGroup!): View!
```

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

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | Interface to application's global information                                               |
| `cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`   | The cursor from which to get the data. The cursor is already moved to the correct position. |
| `parent: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`!` | The parent to which the new view is attached to                                             |

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

### runQueryOnBackgroundThread

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun runQueryOnBackgroundThread(constraint: CharSequence!): Cursor!
```

Runs a query with the specified constraint. This query is requested by the filter attached to this adapter. The query is provided by a[android.widget.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](https://developer.android.com/reference/kotlin/androidx/cursoradapter/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.  

|                                                   Parameters                                                    |
|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `constraint: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!` | the constraint with which the query must be filtered |

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

|                                                                                    See also                                                                                     |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getFilter](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getFilter())                                                             |   |
| [getFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getFilterQueryProvider())                                   |   |
| [setFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider)) |   |

### setFilterQueryProvider

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun setFilterQueryProvider(filterQueryProvider: FilterQueryProvider!): Unit
```

Sets the query filter provider used to filter the current Cursor. The provider's[runQuery](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.  

|                                                            Parameters                                                            |
|----------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `filterQueryProvider: `[FilterQueryProvider](https://developer.android.com/reference/android/widget/FilterQueryProvider.html)`!` | the filter query provider or null to remove it |

|                                                                                  See also                                                                                   |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getFilterQueryProvider](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#getFilterQueryProvider())                               |   |
| [runQueryOnBackgroundThread](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence)) |   |

### swapCursor

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
fun swapCursor(newCursor: Cursor!): Cursor!
```

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

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|----------------------------|
| `newCursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!` | The new cursor to be used. |

|                                      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. |

## Protected functions

### init

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  
Deprecated in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
protected fun [init](https://developer.android.com/reference/kotlin/androidx/cursoradapter/widget/CursorAdapter#init(android.content.Context,android.database.Cursor,boolean))(context: Context!, c: Cursor!, autoRequery: Boolean): Unit
```
| **This function is deprecated.**   
|
Don't use this, use the normal constructor. This will be removed in the future.  

### onContentChanged

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/cursoradapter#1.0.0)  

```
protected fun onContentChanged(): Unit
```

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.  

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