# LoaderManager.LoaderCallbacks

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

# LoaderManager.LoaderCallbacks

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/LoaderManager.LoaderCallbacks "View this page in Kotlin")\|Java

`
public
static


interface
LoaderManager.LoaderCallbacks
`  
`


`

|------------------------------------------------|
| android.app.LoaderManager.LoaderCallbacks\<D\> |

<br />

*** ** * ** ***

<br />

**This interface was deprecated in API level 28.**   
Use the[Support Library](https://developer.android.com/tools/extras/support-library)[LoaderManager.LoaderCallbacks](https://developer.android.com/reference/androidx/loader/app/LoaderManager.LoaderCallbacks.html)

Callback interface for a client to interact with the manager.

## Summary

|                                                                                                                                                                                                        ### Public methods                                                                                                                                                                                                        ||
|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[Loader](https://developer.android.com/reference/android/content/Loader)`<D>` | ` `[onCreateLoader](https://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks#onCreateLoader(int,%20android.os.Bundle))`(int id, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` args) ` Instantiate and return a new Loader for the given ID.                                          |
| ` abstract void`                                                                          | ` `[onLoadFinished](https://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.content.Loader<D>,%20D))`(`[Loader](https://developer.android.com/reference/android/content/Loader)`<D> loader, D data) ` Called when a previously created loader has finished its load.                 |
| ` abstract void`                                                                          | ` `[onLoaderReset](https://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks#onLoaderReset(android.content.Loader<D>))`(`[Loader](https://developer.android.com/reference/android/content/Loader)`<D> loader) ` Called when a previously created loader is being reset, and thus making its data unavailable. |

## Public methods

### onCreateLoader

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Loader<D> onCreateLoader (int id, 
                Bundle args)
```

Instantiate and return a new Loader for the given ID.

<br />

|                           Parameters                           ||
|--------|--------------------------------------------------------|
| `id`   | `int`: The ID whose loader is to be created. <br />    |
| `args` | `Bundle`: Any arguments supplied by the caller. <br /> |

|                                                                      Returns                                                                       ||
|-------------------------------------------------------------------------------|---------------------------------------------------------------------|
| [Loader](https://developer.android.com/reference/android/content/Loader)`<D>` | Return a new Loader instance that is ready to start loading. <br /> |

### onLoadFinished

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void onLoadFinished (Loader<D> loader, 
                D data)
```

Called when a previously created loader has finished its load. Note that normally an application is*not* allowed to commit fragment transactions while in this call, since it can happen after an activity's state is saved. See[FragmentManager.openTransaction()](https://developer.android.com/reference/android/app/FragmentManager#beginTransaction())for further discussion on this.

This function is guaranteed to be called prior to the release of the last data that was supplied for this Loader. At this point you should remove all use of the old data (since it will be released soon), but should not do your own release of the data since its Loader owns it and will take care of that. The Loader will take care of management of its data so you don't have to. In particular:

- The Loader will monitor for changes to the data, and report them to you through new calls here. You should not monitor the data yourself. For example, if the data is a[Cursor](https://developer.android.com/reference/android/database/Cursor)and you place it in a[CursorAdapter](https://developer.android.com/reference/android/widget/CursorAdapter), use the[CursorAdapter.CursorAdapter(android.content.Context, android.database.Cursor, int)](https://developer.android.com/reference/android/widget/CursorAdapter#CursorAdapter(android.content.Context,%20android.database.Cursor,%20int))constructor*without* passing in either[CursorAdapter.FLAG_AUTO_REQUERY](https://developer.android.com/reference/android/widget/CursorAdapter#FLAG_AUTO_REQUERY)or[CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER](https://developer.android.com/reference/android/widget/CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER)(that is, use 0 for the flags argument). This prevents the CursorAdapter from doing its own observing of the Cursor, which is not needed since when a change happens you will get a new Cursor throw another call here.

- The Loader will release the data once it knows the application is no longer using it. For example, if the data is a[Cursor](https://developer.android.com/reference/android/database/Cursor)from a[CursorLoader](https://developer.android.com/reference/android/content/CursorLoader), you should not call close() on it yourself. If the Cursor is being placed in a[CursorAdapter](https://developer.android.com/reference/android/widget/CursorAdapter), you should use the[CursorAdapter.swapCursor(android.database.Cursor)](https://developer.android.com/reference/android/widget/CursorAdapter#swapCursor(android.database.Cursor))method so that the old Cursor is not closed.

<br />

<br />

|                        Parameters                        ||
|----------|------------------------------------------------|
| `loader` | `Loader`: The Loader that has finished. <br /> |
| `data`   | `D`: The data generated by the Loader. <br />  |

### onLoaderReset

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void onLoaderReset (Loader<D> loader)
```

Called when a previously created loader is being reset, and thus making its data unavailable. The application should at this point remove any references it has to the Loader's data.

<br />

|                         Parameters                         ||
|----------|--------------------------------------------------|
| `loader` | `Loader`: The Loader that is being reset. <br /> |