# ResourceCursorAdapter

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

*** ** * ** ***


```
public abstract class ResourceCursorAdapter extends CursorAdapter
```

<br />

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

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

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

*** ** * ** ***

Static library support version of the framework's `https://developer.android.com/reference/android/widget/ResourceCursorAdapter.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

| ### Public constructors |
|---|
| `[ResourceCursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor))(https://developer.android.com/reference/android/content/Context.html context, int layout, https://developer.android.com/reference/android/database/Cursor.html c)` **This method 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 /> |
| `[ResourceCursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor,boolean))( https://developer.android.com/reference/android/content/Context.html context, int layout, https://developer.android.com/reference/android/database/Cursor.html c, boolean autoRequery )` **This method 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 /> |
| `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor,int)(https://developer.android.com/reference/android/content/Context.html context, int layout, https://developer.android.com/reference/android/database/Cursor.html c, int flags)` Standard constructor. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#newDropDownView(android.content.Context,android.database.Cursor,android.view.ViewGroup)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/database/Cursor.html cursor, https://developer.android.com/reference/android/view/ViewGroup.html parent)` Makes a new drop down view to hold the data pointed to by cursor. |
| `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#newView(android.content.Context,android.database.Cursor,android.view.ViewGroup)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/database/Cursor.html cursor, https://developer.android.com/reference/android/view/ViewGroup.html parent)` Inflates view(s) from the specified XML file. |
| `void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#setDropDownViewResource(int)(int dropDownLayout)` Sets the layout resource of the drop down views. |
| `void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#setViewResource(int)(int layout)` Sets the layout resource of the item views. |

| ### Inherited Constants |
|---|
| From [android.widget.Adapter](https://developer.android.com/reference/android/widget/Adapter.html) |---|---| | `static final int` | `https://developer.android.com/reference/android/widget/Adapter.html#IGNORE_ITEM_VIEW_TYPE = -1` | | `static final int` | `https://developer.android.com/reference/android/widget/Adapter.html#NO_SELECTION = -2147483648` | |
| From [androidx.cursoradapter.widget.CursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter) |---|---| | `static final int` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#FLAG_AUTO_REQUERY() = 1` **This field 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 /> | | `static final int` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER() = 2` If set the adapter will register a content observer on the cursor and will call `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#onContentChanged()` when a notification comes in. | |

| ### Inherited methods |
|---|
| From [android.widget.Adapter](https://developer.android.com/reference/android/widget/Adapter.html) |---|---| | `abstract int` | `https://developer.android.com/reference/android/widget/Adapter.html#getCount()()` | | `abstract https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/android/widget/Adapter.html#getItem(int)(int p)` | | `abstract long` | `https://developer.android.com/reference/android/widget/Adapter.html#getItemId(int)(int p)` | | `abstract https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/android/widget/Adapter.html#getView(int, android.view.View, android.view.ViewGroup)(int p, https://developer.android.com/reference/android/view/View.html p1, https://developer.android.com/reference/android/view/ViewGroup.html p2)` | |
| From [android.widget.BaseAdapter](https://developer.android.com/reference/android/widget/BaseAdapter.html) |---|---| | `boolean` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#areAllItemsEnabled()()` | | `CharSequence[]` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#getAutofillOptions()()` | | `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#getDropDownView(int, android.view.View, android.view.ViewGroup)(int position, https://developer.android.com/reference/android/view/View.html convertView, https://developer.android.com/reference/android/view/ViewGroup.html parent)` | | `int` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#getItemViewType(int)(int position)` | | `int` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#getViewTypeCount()()` | | `boolean` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#hasStableIds()()` | | `boolean` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#isEmpty()()` | | `boolean` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#isEnabled(int)(int position)` | | `void` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged()()` | | `void` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetInvalidated()()` | | `void` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#registerDataSetObserver(android.database.DataSetObserver)(https://developer.android.com/reference/android/database/DataSetObserver.html observer)` | | `void` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#setAutofillOptions(java.lang.CharSequence...)(CharSequence[] options)` | | `void` | `https://developer.android.com/reference/android/widget/BaseAdapter.html#unregisterDataSetObserver(android.database.DataSetObserver)(https://developer.android.com/reference/android/database/DataSetObserver.html observer)` | |
| From [androidx.cursoradapter.widget.CursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter) |---|---| | `abstract void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#bindView(android.view.View,android.content.Context,android.database.Cursor)(https://developer.android.com/reference/android/view/View.html view, https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/database/Cursor.html cursor)` Bind an existing view to the data pointed to by cursor | | `void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#changeCursor(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor.html cursor)` Change the underlying cursor to a new cursor. | | `https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#convertToString(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor.html cursor)` Converts the cursor into a CharSequence. | | `int` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getCount()()` | | `https://developer.android.com/reference/android/database/Cursor.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getCursor()()` Returns the cursor. | | `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getDropDownView(int,android.view.View,android.view.ViewGroup)(int position, https://developer.android.com/reference/android/view/View.html convertView, https://developer.android.com/reference/android/view/ViewGroup.html parent)` | | `https://developer.android.com/reference/android/widget/Filter.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getFilter()()` | | `https://developer.android.com/reference/android/widget/FilterQueryProvider.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getFilterQueryProvider()()` Returns the query filter provider used for filtering. | | `https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getItem(int)(int position)` | | `long` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getItemId(int)(int position)` | | `https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#getView(int,android.view.View,android.view.ViewGroup)(int position, https://developer.android.com/reference/android/view/View.html convertView, https://developer.android.com/reference/android/view/ViewGroup.html parent)` | | `boolean` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#hasStableIds()()` | | `void` | `[init](https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#init(android.content.Context,android.database.Cursor,boolean))(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/database/Cursor.html c, boolean autoRequery)` **This method is deprecated.** Don't use this, use the normal constructor. <br /> | | `void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#onContentChanged()()` Called when the `https://developer.android.com/reference/android/database/ContentObserver.html` on the cursor receives a change notification. | | `https://developer.android.com/reference/android/database/Cursor.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#runQueryOnBackgroundThread(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence.html constraint)` Runs a query with the specified constraint. | | `void` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#setFilterQueryProvider(android.widget.FilterQueryProvider)(https://developer.android.com/reference/android/widget/FilterQueryProvider.html filterQueryProvider)` Sets the query filter provider used to filter the current Cursor. | | `https://developer.android.com/reference/android/database/Cursor.html` | `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#swapCursor(android.database.Cursor)(https://developer.android.com/reference/android/database/Cursor.html newCursor)` Swap in a new Cursor, returning the old Cursor. | |
| From [android.widget.Filterable](https://developer.android.com/reference/android/widget/Filterable.html) |---|---| | `abstract https://developer.android.com/reference/android/widget/Filter.html` | `https://developer.android.com/reference/android/widget/Filterable.html#getFilter()()` | |

## Public constructors

### ResourceCursorAdapter

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)

```
public [ResourceCursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor))(Context context, int layout, Cursor c)
```

> [!CAUTION]
> **This method 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 `https://developer.android.com/reference/android/app/LoaderManager.html` with a `https://developer.android.com/reference/android/content/CursorLoader.html`.

Constructor the enables auto-requery.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context where the ListView associated with this adapter is running |
| `int layout` | resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views. |

### ResourceCursorAdapter

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)

```
public [ResourceCursorAdapter](https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor,boolean))(
    Context context,
    int layout,
    Cursor c,
    boolean autoRequery
)
```

> [!CAUTION]
> **This method 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 `https://developer.android.com/reference/android/app/LoaderManager.html` with a `https://developer.android.com/reference/android/content/CursorLoader.html`.

Constructor with default behavior as per `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor,boolean)`; it is recommended you not use this, but instead `https://developer.android.com/reference/androidx/cursoradapter/widget/ResourceCursorAdapter#ResourceCursorAdapter(android.content.Context,int,android.database.Cursor,int)`. When using this constructor, `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER()` will always be set.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context where the ListView associated with this adapter is running |
| `int layout` | resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views. |
| `https://developer.android.com/reference/android/database/Cursor.html c` | The cursor from which to get the data. |
| `boolean autoRequery` | 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. |

### ResourceCursorAdapter

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

```
public ResourceCursorAdapter(Context context, int layout, Cursor c, int flags)
```

Standard constructor.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context where the ListView associated with this adapter is running |
| `int layout` | Resource identifier of a layout file that defines the views for this list item. Unless you override them later, this will define both the item views and the drop down views. |
| `https://developer.android.com/reference/android/database/Cursor.html c` | The cursor from which to get the data. |
| `int flags` | Flags used to determine the behavior of the adapter, as per `https://developer.android.com/reference/androidx/cursoradapter/widget/CursorAdapter#CursorAdapter(android.content.Context,android.database.Cursor,int)`. |

## Public methods

### newDropDownView

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

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/View.html` | the newly created view. |

### newView

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

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

Inflates view(s) from the specified XML file.

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/CursorAdapter.html#newView(android.content.Context, android.database.Cursor, android.view.ViewGroup)` |   |

### setDropDownViewResource

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

```
public void setDropDownViewResource(int dropDownLayout)
```

Sets the layout resource of the drop down views.

| Parameters |
|---|---|
| `int dropDownLayout` | the layout resources used to create drop down views |

### setViewResource

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

```
public void setViewResource(int layout)
```

Sets the layout resource of the item views.

| Parameters |
|---|---|
| `int layout` | the layout resources used to create item views |