# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Constants | Inherited Constants | Ctors | Methods | Protected Methods | Inherited Methods

# CursorAdapter

`public abstract class CursorAdapter`
`` `extends BaseAdapter` `implements Filterable, ThemedSpinnerAdapter`

java.lang.Object
↳ | android.widget.BaseAdapter
| ↳ | android.widget.CursorAdapter

Known direct subclasses ResourceCursorAdapter
ResourceCursorAdapter | An easy adapter that creates views defined in an XML file.

Known indirect subclasses SimpleCursorAdapter
SimpleCursorAdapter | An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file.

Adapter that exposes data from a `Cursor` to a `ListView` widget.

The Cursor must include a column named "_id" or this class will not work. Additionally, using `MergeCursor` with this class will not work if the merged Cursors have overlapping values in their "_id" columns.

## Summary

### Constants
`int` | `FLAG_AUTO_REQUERY` This constant 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 `LoaderManager` with a `CursorLoader`.
`int` | `FLAG_REGISTER_CONTENT_OBSERVER` If set the adapter will register a content observer on the cursor and will call `onContentChanged()` when a notification comes in.

### Inherited constants
From interface `android.widget.Adapter`
`int` | `IGNORE_ITEM_VIEW_TYPE` An item view type that causes the `AdapterView` to ignore the item view.
`int` | `NO_SELECTION`

### Public constructors
`CursorAdapter(Context context, Cursor c)` This constructor 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 `LoaderManager` with a `CursorLoader`.
`CursorAdapter(Context context, Cursor c, boolean autoRequery)` Constructor that allows control over auto-requery.
`CursorAdapter(Context context, Cursor c, int flags)` Recommended constructor.

### Public methods
`abstract void` | `bindView(View view, Context context, Cursor cursor)` Bind an existing view to the data pointed to by cursor
`void` | `changeCursor(Cursor cursor)` Change the underlying cursor to a new cursor.
`CharSequence` | `convertToString(Cursor cursor)` Converts the cursor into a CharSequence.
`int` | `getCount()` How many items are in the data set represented by this Adapter.
`Cursor` | `getCursor()` Returns the cursor.
`View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
`Resources.Theme` | `getDropDownViewTheme()` Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.
`Filter` | `getFilter()` Returns a filter that can be used to constrain data with a filtering pattern.
`FilterQueryProvider` | `getFilterQueryProvider()` Returns the query filter provider used for filtering.
`Object` | `getItem(int position)` Get the data item associated with the specified position in the data set.
`long` | `getItemId(int position)` Get the row id associated with the specified position in the list.
`View` | `getView(int position, View convertView, ViewGroup parent)` Get a View that displays the data at the specified position in the data set.
`boolean` | `hasStableIds()` Indicates whether the item ids are stable across changes to the underlying data.
`View` | `newDropDownView(Context context, Cursor cursor, ViewGroup parent)` Makes a new drop down view to hold the data pointed to by cursor.
`abstract View` | `newView(Context context, Cursor cursor, ViewGroup parent)` Makes a new view to hold the data pointed to by cursor.
`Cursor` | `runQueryOnBackgroundThread(CharSequence constraint)` Runs a query with the specified constraint.
`void` | `setDropDownViewTheme(Resources.Theme theme)` Sets the `Resources.Theme` against which drop-down views are inflated.
`void` | `setFilterQueryProvider(FilterQueryProvider filterQueryProvider)` Sets the query filter provider used to filter the current Cursor.
`Cursor` | `swapCursor(Cursor newCursor)` Swap in a new Cursor, returning the old Cursor.

### Protected methods
`void` | `init(Context context, Cursor c, boolean autoRequery)` This method is deprecated. Don't use this, use the normal constructor. This will be removed in the future.
`void` | `onContentChanged()` Called when the `ContentObserver` on the cursor receives a change notification.

### Inherited methods
From class `android.widget.BaseAdapter`
`boolean` | `areAllItemsEnabled()` Indicates whether all the items in this adapter are enabled.
`CharSequence[]` | `getAutofillOptions()` Gets a string representation of the adapter data that can help `AutofillService` autofill the view backed by the adapter.
`View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
`int` | `getItemViewType(int position)` Get the type of View that will be created by `getView(int, View, ViewGroup)` for the specified item.
`int` | `getViewTypeCount()` Returns the number of types of Views that will be created by `getView(int, View, ViewGroup)`.
`boolean` | `hasStableIds()` Indicates whether the item ids are stable across changes to the underlying data.
`boolean` | `isEmpty()`
`boolean` | `isEnabled(int position)` Returns true if the item at the specified position is not a separator.
`void` | `notifyDataSetChanged()` Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
`void` | `notifyDataSetInvalidated()` Notifies the attached observers that the underlying data is no longer valid or available.
`void` | `registerDataSetObserver(DataSetObserver observer)` Register an observer that is called when changes happen to the data used by this adapter.
`void` | `setAutofillOptions(CharSequence... options)` Sets the value returned by `getAutofillOptions()`
`void` | `unregisterDataSetObserver(DataSetObserver observer)` Unregister an observer that has previously been registered with this adapter via `registerDataSetObserver(DataSetObserver)`.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `android.widget.ListAdapter`
`abstract boolean` | `areAllItemsEnabled()` Indicates whether all the items in this adapter are enabled.
`abstract boolean` | `isEnabled(int position)` Returns true if the item at the specified position is not a separator.
From interface `android.widget.SpinnerAdapter`
`abstract View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
From interface `android.widget.Filterable`
`abstract Filter` | `getFilter()` Returns a filter that can be used to constrain data with a filtering pattern.
From interface `android.widget.ThemedSpinnerAdapter`
`abstract Resources.Theme` | `getDropDownViewTheme()` Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.
`abstract void` | `setDropDownViewTheme(Resources.Theme theme)` Sets the `Resources.Theme` against which drop-down views are inflated.
From interface `android.widget.Adapter`
`default CharSequence[]` | `getAutofillOptions()` Gets a string representation of the adapter data that can help `AutofillService` autofill the view backed by the adapter.
`abstract int` | `getCount()` How many items are in the data set represented by this Adapter.
`abstract Object` | `getItem(int position)` Get the data item associated with the specified position in the data set.
`abstract long` | `getItemId(int position)` Get the row id associated with the specified position in the list.
`abstract int` | `getItemViewType(int position)` Get the type of View that will be created by `getView(int, View, ViewGroup)` for the specified item.
`abstract View` | `getView(int position, View convertView, ViewGroup parent)` Get a View that displays the data at the specified position in the data set.
`abstract int` | `getViewTypeCount()` Returns the number of types of Views that will be created by `getView(int, View, ViewGroup)`.
`abstract boolean` | `hasStableIds()` Indicates whether the item ids are stable across changes to the underlying data.
`abstract boolean` | `isEmpty()`
`abstract void` | `registerDataSetObserver(DataSetObserver observer)` Register an observer that is called when changes happen to the data used by this adapter.
`abstract void` | `unregisterDataSetObserver(DataSetObserver observer)` Unregister an observer that has previously been registered with this adapter via `registerDataSetObserver(DataSetObserver)`.

## Constants

### FLAG_AUTO_REQUERY

    public static final int FLAG_AUTO_REQUERY

This constant 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 `LoaderManager` with a `CursorLoader`.

If set the adapter will call requery() on the cursor whenever a content change notification is delivered. Implies `FLAG_REGISTER_CONTENT_OBSERVER`.

Constant Value: 1 (0x00000001)

### FLAG_REGISTER_CONTENT_OBSERVER

    public static final int FLAG_REGISTER_CONTENT_OBSERVER

If set the adapter will register a content observer on the cursor and will call `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`.

Constant Value: 2 (0x00000002)

## Public constructors

### CursorAdapter

    public CursorAdapter (Context context,
                    Cursor c)

This constructor 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 `LoaderManager` with a `CursorLoader`.

Constructor that always enables auto-requery.

Parameters
`context` | `Context`: The context
`c` | `Cursor`: The cursor from which to get the data.

### CursorAdapter

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

Constructor that allows control over auto-requery. It is recommended you not use this, but instead `CursorAdapter(android.content.Context, android.database.Cursor, int)`. When using this constructor, `FLAG_REGISTER_CONTENT_OBSERVER` will always be set.

Parameters
`context` | `Context`: The context
`c` | `Cursor`: The cursor from which to get the data.
`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.

### CursorAdapter

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

Recommended constructor.

Parameters
`context` | `Context`: The context
`c` | `Cursor`: The cursor from which to get the data.
`flags` | `int`: Flags used to determine the behavior of the adapter; may be any combination of `FLAG_AUTO_REQUERY` and `FLAG_REGISTER_CONTENT_OBSERVER`.

## Public methods

### bindView

    public abstract void bindView (View view,
                    Context context,
                    Cursor cursor)

Bind an existing view to the data pointed to by cursor

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

### changeCursor

    public void changeCursor (Cursor cursor)

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

Parameters
`cursor` | `Cursor`: The new cursor to be used

### convertToString

    public CharSequence convertToString (Cursor cursor)

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`: the cursor to convert to a CharSequence

Returns
`CharSequence` | a CharSequence representing the value

### getCount

    public int getCount ()

How many items are in the data set represented by this Adapter.

Returns
`int` | Count of items.

See also:

- `Adapter.getCount()`

### getCursor

    public Cursor getCursor ()

Returns the cursor.

Returns
`Cursor` | the cursor.

### getDropDownView

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

Gets a `View` that displays in the drop down popup the data at the specified position in the data set.

Parameters
`position` | `int`: index of the item whose view we want.
`convertView` | `View`: the old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view.
`parent` | `ViewGroup`: the parent that this view will eventually be attached to

Returns
`View` | a `View` corresponding to the data at the specified position.

### getDropDownViewTheme

    public Resources.Theme getDropDownViewTheme ()

Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.

Returns
`Resources.Theme` | the `Resources.Theme` against which drop-down views are inflated, or `null` if one has not been explicitly set

### getFilter

    public Filter getFilter ()

Returns a filter that can be used to constrain data with a filtering pattern.

This method is usually implemented by `Adapter` classes.

Returns
`Filter` | a filter used to constrain data

### getFilterQueryProvider

    public FilterQueryProvider getFilterQueryProvider ()

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

Returns
`FilterQueryProvider` | the current filter query provider or null if it does not exist

See also:

- `setFilterQueryProvider(android.widget.FilterQueryProvider)`
- `runQueryOnBackgroundThread(CharSequence)`

### getItem

    public Object getItem (int position)

Get the data item associated with the specified position in the data set.

Parameters
`position` | `int`: Position of the item whose data we want within the adapter's data set.

Returns
`Object` | The data at the specified position.

See also:

- `Adapter.getItem(int)`

### getItemId

    public long getItemId (int position)

Get the row id associated with the specified position in the list.

Parameters
`position` | `int`: The position of the item within the adapter's data set whose row id we want.

Returns
`long` | The id of the item at the specified position.

See also:

- `Adapter.getItemId(int)`

### getView

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

Get a View that displays the data at the specified position in the data set. You can either create a View manually or inflate it from an XML layout file. When the View is inflated, the parent View (GridView, ListView...) will apply default layout parameters unless you use `LayoutInflater.inflate(int, android.view.ViewGroup, boolean)` to specify a root view and to prevent attachment to the root.

Parameters
`position` | `int`: The position of the item within the adapter's data set of the item whose view we want.
`convertView` | `View`: The old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. Heterogeneous lists can specify their number of view types, so that this View is always of the right type (see `BaseAdapter.getViewTypeCount()` and `BaseAdapter.getItemViewType(int)`).
`parent` | `ViewGroup`: The parent that this view will eventually be attached to

Returns
`View` | A View corresponding to the data at the specified position.

See also:

- `Adapter.getView(int, View, ViewGroup)`

### hasStableIds

    public boolean hasStableIds ()

Indicates whether the item ids are stable across changes to the underlying data.

Returns
`boolean` | True if the same id always refers to the same object.

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

Returns
`View` | the newly created view.

### newView

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

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

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

Returns
`View` | the newly created view.

### runQueryOnBackgroundThread

    public 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`. If no provider is specified, the current cursor is not filtered and returned. After this method returns the resulting cursor is passed to `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.
This method may take several seconds to complete, so it should only be called from a worker thread.

Parameters
`constraint` | `CharSequence`: the constraint with which the query must be filtered

Returns
`Cursor` | a Cursor representing the results of the new query

See also:

- `getFilter()`
- `getFilterQueryProvider()`
- `setFilterQueryProvider(android.widget.FilterQueryProvider)`

### setDropDownViewTheme

    public void setDropDownViewTheme (Resources.Theme theme)

Sets the `Resources.Theme` against which drop-down views are inflated.

By default, drop-down views are inflated against the theme of the `Context` passed to the adapter's constructor.

Parameters
`theme` | `Resources.Theme`: the theme against which to inflate drop-down views or `null` to use the theme from the adapter's context

See also:

- `newDropDownView(Context, Cursor, ViewGroup)`

### setFilterQueryProvider

    public void setFilterQueryProvider (FilterQueryProvider filterQueryProvider)

Sets the query filter provider used to filter the current Cursor. The provider's `FilterQueryProvider.runQuery(CharSequence)` method is invoked when filtering is requested by a client of this adapter.

Parameters
`filterQueryProvider` | `FilterQueryProvider`: the filter query provider or null to remove it

See also:

- `getFilterQueryProvider()`
- `runQueryOnBackgroundThread(CharSequence)`

### swapCursor

    public Cursor swapCursor (Cursor newCursor)

Swap in a new Cursor, returning the old Cursor. Unlike `changeCursor(android.database.Cursor)`, the returned old Cursor is not closed.

Parameters
`newCursor` | `Cursor`: The new cursor to be used.

Returns
`Cursor` | 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 methods

### init

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

This method is deprecated.
Don't use this, use the normal constructor. This will be removed in the future.

Parameters
`context` | `Context`
`c` | `Cursor`
`autoRequery` | `boolean`

### onContentChanged

    protected void onContentChanged ()

Called when the `ContentObserver` on the cursor receives a change notification. The default implementation provides the auto-requery logic, but may be overridden by sub classes.

See also:

- `ContentObserver.onChange(boolean)`

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*