# CursorObjectAdapter

# CursorObjectAdapter

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

*** ** * ** ***

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

<br />

```
class CursorObjectAdapter : ObjectAdapter
```

<br />

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

*** ** * ** ***

An[ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter)implemented with a[Cursor](https://developer.android.com/reference/android/database/Cursor.html).

## Summary

|                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                             |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CursorObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#CursorObjectAdapter())`()` Constructs an adapter.                                                                                                                                                                                                                                                                                                            |
| [CursorObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#CursorObjectAdapter(androidx.leanback.widget.Presenter))`(presenter: `[Presenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter)`!)` Constructs an adapter that uses the given[Presenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter)for all items.                               |
| [CursorObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#CursorObjectAdapter(androidx.leanback.widget.PresenterSelector))`(presenterSelector: `[PresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector)`!)` Constructs an adapter with the given[PresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector). |

|                                           ### Public functions                                            |
|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                             | [changeCursor](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#changeCursor(android.database.Cursor))`(cursor: `[Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!)` Changes the underlying cursor to a new cursor.                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                             | [close](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#close())`()` Closes this adapter, closing the backing[Cursor](https://developer.android.com/reference/android/database/Cursor.html)as well.                                                                                                                                                                                                                                                                |
| [Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?`                            | [get](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#get(int))`(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the item for the given position.                                                                                                                                                                                                                                                                   |
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`                         | [getCursor](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#getCursor())`()` Returns the[Cursor](https://developer.android.com/reference/android/database/Cursor.html)backing the adapter.                                                                                                                                                                                                                                                                         |
| [CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)`!` | [getMapper](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#getMapper())`()` Returns the[CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)used to convert[Cursor](https://developer.android.com/reference/android/database/Cursor.html)rows into Objects.                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                       | [isClosed](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#isClosed())`()` Returns true if the adapter, and hence the backing[Cursor](https://developer.android.com/reference/android/database/Cursor.html), is closed; false otherwise.                                                                                                                                                                                                                           |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                       | [isImmediateNotifySupported](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#isImmediateNotifySupported())`()` Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.                                                                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                             | [setMapper](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#setMapper(androidx.leanback.database.CursorMapper))`(mapper: `[CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)`!)` Sets the[CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)used to convert[Cursor](https://developer.android.com/reference/android/database/Cursor.html)rows into Objects. |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                               | [size](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#size())`()` Returns the number of items in the adapter.                                                                                                                                                                                                                                                                                                                                                     |
| [Cursor](https://developer.android.com/reference/android/database/Cursor.html)`!`                         | [swapCursor](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#swapCursor(android.database.Cursor))`(cursor: `[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) | [invalidateCache](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#invalidateCache(int))`(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Removes an item from the cache.                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [invalidateCache](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#invalidateCache(int,int))`(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Removes`count`items starting at`index`. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onCursorChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#onCursorChanged())`()` Called whenever the cursor changes.                                                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onMapperChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#onMapperChanged())`()` Called when[setMapper](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#setMapper(androidx.leanback.database.CursorMapper))is called and a different mapper is provided.      |

|                                                                                                                                                                                                                                                                                                      ### Inherited Constants                                                                                                                                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.leanback.widget.ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter) |-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [NO_ID](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#NO_ID())` = -1` Indicates that an id has not been set. | |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.leanback.widget.ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter) |----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | [getId](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#getId(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the id for the given position.                                                                                                                                                                                                                                                  | | [Presenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter)`?`              | [getPresenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#getPresenter(java.lang.Object))`(item: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`)` Returns the[Presenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter)for the given item from the adapter.                                                                                                                    | | [PresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector) | [getPresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#getPresenterSelector())`()` Returns the presenter selector for this ObjectAdapter.                                                                                                                                                                                                                                                                                              | | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                            | [hasStableIds](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#hasStableIds())`()` Returns true if the item ids are stable across changes to the underlying data.                                                                                                                                                                                                                                                                                      | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyChanged())`()` Notifies UI that the underlying data has changed.                                                                                                                                                                                                                                                                                                                 | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyItemMoved](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemMoved(int,int))`(fromPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, toPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies UI that item at fromPosition has been moved to toPosition.                                                                                              | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeChanged(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies UI that some items has changed.                                                                                                           | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyItemRangeChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeChanged(int,int,java.lang.Object))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, payload: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)` Notifies UI that some items has changed. | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyItemRangeInserted](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeInserted(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies UI that new items has been inserted.                                                                                                    | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [notifyItemRangeRemoved](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeRemoved(int,int))`(positionStart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, itemCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies UI that some items that has been removed.                                                                                                 | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [onHasStableIdsChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#onHasStableIdsChanged())`()` Called when[setHasStableIds](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setHasStableIds(boolean))is called and the status of stable ids has changed.                                                                                                                                                   | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [onPresenterSelectorChanged](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#onPresenterSelectorChanged())`()` Called when[setPresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setPresenterSelector(androidx.leanback.widget.PresenterSelector))is called and the PresenterSelector differs from the previous one.                                                                             | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [registerObserver](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#registerObserver(androidx.leanback.widget.ObjectAdapter.DataObserver))`(observer: `[ObjectAdapter.DataObserver](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver)`)` Registers a DataObserver for data change notifications.                                                                                                      | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [setHasStableIds](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setHasStableIds(boolean))`(hasStableIds: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Sets whether the item ids are stable across changes to the underlying data.                                                                                                                                                                         | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [setPresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setPresenterSelector(androidx.leanback.widget.PresenterSelector))`(presenterSelector: `[PresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector)`)` Sets the presenter selector.                                                                                                                                           | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [unregisterAllObservers](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#unregisterAllObservers())`()` Unregisters all DataObservers for this ObjectAdapter.                                                                                                                                                                                                                                                                                           | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [unregisterObserver](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#unregisterObserver(androidx.leanback.widget.ObjectAdapter.DataObserver))`(observer: `[ObjectAdapter.DataObserver](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver)`)` Unregisters a DataObserver for data change notifications.                                                                                                | |

## Public constructors

### CursorObjectAdapter

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

```
CursorObjectAdapter()
```

Constructs an adapter.  

### CursorObjectAdapter

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

```
CursorObjectAdapter(presenter: Presenter!)
```

Constructs an adapter that uses the given[Presenter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter)for all items.  

### CursorObjectAdapter

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

```
CursorObjectAdapter(presenterSelector: PresenterSelector!)
```

Constructs an adapter with the given[PresenterSelector](https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector).  

## Public functions

### changeCursor

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

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

Changes the underlying cursor to a new cursor. If there is an existing cursor it will be closed if it is different than the new cursor.  

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

### close

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

```
fun close(): Unit
```

Closes this adapter, closing the backing[Cursor](https://developer.android.com/reference/android/database/Cursor.html)as well.  

### get

```
fun get(index: Int): Any?
```

Returns the item for the given position.  

### getCursor

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

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

Returns the[Cursor](https://developer.android.com/reference/android/database/Cursor.html)backing the adapter.  

### getMapper

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

```
fun getMapper(): CursorMapper!
```

Returns the[CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)used to convert[Cursor](https://developer.android.com/reference/android/database/Cursor.html)rows into Objects.  

### isClosed

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

```
fun isClosed(): Boolean
```

Returns true if the adapter, and hence the backing[Cursor](https://developer.android.com/reference/android/database/Cursor.html), is closed; false otherwise.  

### isImmediateNotifySupported

```
fun isImmediateNotifySupported(): Boolean
```

Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.  

### setMapper

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

```
fun setMapper(mapper: CursorMapper!): Unit
```

Sets the[CursorMapper](https://developer.android.com/reference/kotlin/androidx/leanback/database/CursorMapper)used to convert[Cursor](https://developer.android.com/reference/android/database/Cursor.html)rows into Objects.  

### size

```
fun size(): Int
```

Returns the number of items in the adapter.  

### swapCursor

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

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

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

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

## Protected functions

### invalidateCache

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

```
protected fun invalidateCache(index: Int): Unit
```

Removes an item from the cache. This will force the item to be re-read from the data source the next time[get](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#get(int))is called.  

### invalidateCache

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

```
protected fun invalidateCache(index: Int, count: Int): Unit
```

Removes`count`items starting at`index`.  

### onCursorChanged

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

```
protected fun onCursorChanged(): Unit
```

Called whenever the cursor changes.  

### onMapperChanged

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

```
protected fun onMapperChanged(): Unit
```

Called when[setMapper](https://developer.android.com/reference/kotlin/androidx/leanback/widget/CursorObjectAdapter#setMapper(androidx.leanback.database.CursorMapper))is called and a different mapper is provided.