# LoaderManager

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:loader:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v4/app/LoaderManager#nestedclasses)\|[Ctors](https://developer.android.com/reference/android/support/v4/app/LoaderManager#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/app/LoaderManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/app/LoaderManager#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/app/LoaderManager#)  

# LoaderManager

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


abstract
class
LoaderManager
`  
`

extends Object


``


`

|---|--------------------------------------|
| java.lang.Object                        ||
| ↳ | android.support.v4.app.LoaderManager |

<br />

*** ** * ** ***

Static library support version of the framework's[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager.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.

Your activity must derive from[FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)to use this.

## Summary

|                                                                                               ### Nested classes                                                                                               ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [LoaderManager.LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)`<D>` Callback interface for a client to interact with the manager. |

|                                                 ### Public constructors                                                  ||
|-----------------------------------------------------------------------------------------------------------------------|---|
| ` `[LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager#LoaderManager())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                                                                                                         | ` `[destroyLoader](https://developer.android.com/reference/android/support/v4/app/LoaderManager#destroyLoader(int))`(int id) ` Stops and removes the loader with the given ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` abstract void`                                                                                                                                         | ` `[dump](https://developer.android.com/reference/android/support/v4/app/LoaderManager#dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]))`(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) ` Print the LoaderManager's state into the given stream.                                                                                                                                                                                                                                                                                                                                                     |
| ` static void`                                                                                                                                           | ` `[enableDebugLogging](https://developer.android.com/reference/android/support/v4/app/LoaderManager#enableDebugLogging(boolean))`(boolean enabled) ` Control whether the framework's internal loader manager debugging logs are turned on.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` static <T extends LifecycleOwner & ViewModelStoreOwner> `[LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager) | ` `[getInstance](https://developer.android.com/reference/android/support/v4/app/LoaderManager#getInstance(T))`(T owner) ` Gets a LoaderManager associated with the given owner, such as a[FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)or[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment).                                                                                                                                                                                                                                                                                 |
| ` abstract <D> `[Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>`                                                 | ` `[getLoader](https://developer.android.com/reference/android/support/v4/app/LoaderManager#getLoader(int))`(int id) ` Return the Loader with the given id or null if no matching Loader is found.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                                                               | ` `[hasRunningLoaders](https://developer.android.com/reference/android/support/v4/app/LoaderManager#hasRunningLoaders())`() ` Returns true if any loaders managed are currently running and have not returned data to the application yet.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` abstract <D> `[Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>`                                                 | ` `[initLoader](https://developer.android.com/reference/android/support/v4/app/LoaderManager#initLoader(int, android.os.Bundle, android.support.v4.app.LoaderManager.LoaderCallbacks<D>))`(int id, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` args, `[LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)`<D> callback) ` Ensures a loader is initialized and active.                                                                                                                                                                                                   |
| ` abstract void`                                                                                                                                         | ` `[markForRedelivery](https://developer.android.com/reference/android/support/v4/app/LoaderManager#markForRedelivery())`() ` Mark all Loaders associated with this LoaderManager for redelivery of their current data (if any), waiting for the next time the Loader is started if it is currently stopped.                                                                                                                                                                                                                                                                                                                                                       |
| ` abstract <D> `[Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>`                                                 | ` `[restartLoader](https://developer.android.com/reference/android/support/v4/app/LoaderManager#restartLoader(int, android.os.Bundle, android.support.v4.app.LoaderManager.LoaderCallbacks<D>))`(int id, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` args, `[LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)`<D> callback) ` Starts a new or restarts an existing[Loader](https://developer.android.com/reference/android/content/Loader.html)in this manager, registers the callbacks to it, and (if the activity/fragment is currently started) starts loading it. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/LoaderManager#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### LoaderManager

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
LoaderManager ()
```

<br />

<br />

## Public methods

### destroyLoader

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void destroyLoader (int id)
```

Stops and removes the loader with the given ID. If this loader had previously reported data to the client through[onLoadFinished(Loader, Object)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader<D>, D)), a call will be made to[onLoaderReset(Loader)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoaderReset(android.support.v4.content.Loader<D>)).

Must be called from the process's main thread.

<br />

|     Parameters     ||
|------|--------------|
| `id` | `int` <br /> |

### dump

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void dump (String prefix, 
                FileDescriptor fd, 
                PrintWriter writer, 
                String[] args)
```

Print the LoaderManager's state into the given stream.

<br />

|                                         Parameters                                         ||
|----------|----------------------------------------------------------------------------------|
| `prefix` | `String`: Text to print at the front of each line. <br />                        |
| `fd`     | `FileDescriptor`: The raw file descriptor that the dump is being sent to. <br /> |
| `writer` | `PrintWriter`: A PrintWriter to which the dump is to be set. <br />              |
| `args`   | `String`: Additional arguments to the dump request. <br />                       |

### enableDebugLogging

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void enableDebugLogging (boolean enabled)
```

Control whether the framework's internal loader manager debugging logs are turned on. If enabled, you will see output in logcat as the framework performs loader operations.

<br />

|         Parameters          ||
|-----------|------------------|
| `enabled` | `boolean` <br /> |

### getInstance

```
LoaderManager getInstance (T owner)
```

Gets a LoaderManager associated with the given owner, such as a[FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)or[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment).

<br />

|                                       Parameters                                        ||
|---------|--------------------------------------------------------------------------------|
| `owner` | `T`: The owner that should be used to create the returned LoaderManager <br /> |

|                                                           Returns                                                           ||
|-----------------------------------------------------------------------------------------------|------------------------------|
| [LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager) | A valid LoaderManager <br /> |

### getLoader

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Loader<D> getLoader (int id)
```

Return the Loader with the given id or null if no matching Loader is found.

<br />

|     Parameters     ||
|------|--------------|
| `id` | `int` <br /> |

|                                             Returns                                              ||
|------------------------------------------------------------------------------------------|--------|
| [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>` | <br /> |

### hasRunningLoaders

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean hasRunningLoaders ()
```

Returns true if any loaders managed are currently running and have not returned data to the application yet.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### initLoader

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Loader<D> initLoader (int id, 
                Bundle args, 
                LoaderCallbacks<D> callback)
```

Ensures a loader is initialized and active. If the loader doesn't already exist, one is created and (if the activity/fragment is currently started) starts the loader. Otherwise the last created loader is re-used.

In either case, the given callback is associated with the loader, and will be called as the loader state changes. If at the point of call the caller is in its started state, and the requested loader already exists and has generated its data, then callback[onLoadFinished(Loader, D)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader<D>, D))will be called immediately (inside of this function), so you must be prepared for this to happen.

Must be called from the process's main thread.

<br />

|                                                                                                               Parameters                                                                                                                ||
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`       | `int`: A unique identifier for this loader. Can be whatever you want. Identifiers are scoped to a particular LoaderManager instance. <br />                                                                                 |
| `args`     | `Bundle`: Optional arguments to supply to the loader at construction. If a loader already exists (a new one does not need to be created), this parameter will be ignored and the last arguments continue to be used. <br /> |
| `callback` | `LoaderCallbacks`: Interface the LoaderManager will call to report about changes in the state of the loader. Required. <br />                                                                                               |

|                                             Returns                                              ||
|------------------------------------------------------------------------------------------|--------|
| [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>` | <br /> |

### markForRedelivery

```
void markForRedelivery ()
```

Mark all Loaders associated with this LoaderManager for redelivery of their current data (if any), waiting for the next time the Loader is started if it is currently stopped. In cases where no data has yet been delivered, this is effectively a no-op. In cases where data has already been delivered via[onLoadFinished(Loader, Object)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader<D>, D)), this will ensure that[onLoadFinished(Loader, Object)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader<D>, D))is called again with the same data.

Call this only if you are implementing a[LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)where the views/elements that developers are likely to use in[onLoadFinished(Loader, Object)](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader<D>, D))can be created and destroyed multiple times without the[LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)itself being destroyed. Call this when the views/elements are being destroyed to ensure that the data is redelivered upon recreation.

<br />

### restartLoader

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Loader<D> restartLoader (int id, 
                Bundle args, 
                LoaderCallbacks<D> callback)
```

Starts a new or restarts an existing[Loader](https://developer.android.com/reference/android/content/Loader.html)in this manager, registers the callbacks to it, and (if the activity/fragment is currently started) starts loading it. If a loader with the same id has previously been started it will automatically be destroyed when the new loader completes its work. The callback will be delivered before the old loader is destroyed.

Must be called from the process's main thread.

<br />

|                                                                       Parameters                                                                        ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `id`       | `int`: A unique identifier for this loader. Can be whatever you want. Identifiers are scoped to a particular LoaderManager instance. <br /> |
| `args`     | `Bundle`: Optional arguments to supply to the loader at construction. <br />                                                                |
| `callback` | `LoaderCallbacks`: Interface the LoaderManager will call to report about changes in the state of the loader. Required. <br />               |

|                                             Returns                                              ||
|------------------------------------------------------------------------------------------|--------|
| [Loader](https://developer.android.com/reference/android/support/v4/content/Loader)`<D>` | <br /> |

-

  ## Annotations

  - [NotificationCompat.Action.SemanticAction](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.SemanticAction)
-

  ## Interfaces

  - [ActionBarDrawerToggle.Delegate](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.Delegate)
  - [ActionBarDrawerToggle.DelegateProvider](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.DelegateProvider)
  - [ActivityCompat.OnRequestPermissionsResultCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback)
  - [ActivityCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.PermissionCompatDelegate)
  - [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/support/v4/app/FragmentManager.BackStackEntry)
  - [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)
  - [LoaderManager.LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)
  - [NotificationCompat.Action.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Extender)
  - [NotificationCompat.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Extender)
  - [SharedElementCallback.OnSharedElementsReadyListener](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback.OnSharedElementsReadyListener)
  - [TaskStackBuilder.SupportParentable](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.SupportParentable)
-

  ## Classes

  - [ActionBarDrawerToggle](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle)
  - [ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)
  - [ActivityManagerCompat](https://developer.android.com/reference/android/support/v4/app/ActivityManagerCompat)
  - [ActivityOptionsCompat](https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat)
  - [AlarmManagerCompat](https://developer.android.com/reference/android/support/v4/app/AlarmManagerCompat)
  - [AppLaunchChecker](https://developer.android.com/reference/android/support/v4/app/AppLaunchChecker)
  - [AppOpsManagerCompat](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat)
  - [BundleCompat](https://developer.android.com/reference/android/support/v4/app/BundleCompat)
  - [DialogFragment](https://developer.android.com/reference/android/support/v4/app/DialogFragment)
  - [Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)
  - [Fragment.SavedState](https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState)
  - [FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)
  - [FragmentContainer](https://developer.android.com/reference/android/support/v4/app/FragmentContainer)
  - [FragmentController](https://developer.android.com/reference/android/support/v4/app/FragmentController)
  - [FragmentHostCallback](https://developer.android.com/reference/android/support/v4/app/FragmentHostCallback)
  - [FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)
  - [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)
  - [FragmentManagerNonConfig](https://developer.android.com/reference/android/support/v4/app/FragmentManagerNonConfig)
  - [FragmentPagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter)
  - [FragmentStatePagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter)
  - [FragmentTabHost](https://developer.android.com/reference/android/support/v4/app/FragmentTabHost)
  - [FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)
  - [FrameMetricsAggregator](https://developer.android.com/reference/android/support/v4/app/FrameMetricsAggregator)
  - [JobIntentService](https://developer.android.com/reference/android/support/v4/app/JobIntentService)
  - [ListFragment](https://developer.android.com/reference/android/support/v4/app/ListFragment)
  - [LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager)
  - [NavUtils](https://developer.android.com/reference/android/support/v4/app/NavUtils)
  - [NotificationCompat](https://developer.android.com/reference/android/support/v4/app/NotificationCompat)
  - [NotificationCompat.Action](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action)
  - [NotificationCompat.Action.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Builder)
  - [NotificationCompat.Action.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.WearableExtender)
  - [NotificationCompat.BigPictureStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigPictureStyle)
  - [NotificationCompat.BigTextStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigTextStyle)
  - [NotificationCompat.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder)
  - [NotificationCompat.CarExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender)
  - [NotificationCompat.CarExtender.UnreadConversation](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation)
  - [NotificationCompat.CarExtender.UnreadConversation.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation.Builder)
  - [NotificationCompat.DecoratedCustomViewStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.DecoratedCustomViewStyle)
  - [NotificationCompat.InboxStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.InboxStyle)
  - [NotificationCompat.MessagingStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle)
  - [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle.Message)
  - [NotificationCompat.Style](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Style)
  - [NotificationCompat.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender)
  - [NotificationCompatExtras](https://developer.android.com/reference/android/support/v4/app/NotificationCompatExtras)
  - [NotificationCompatSideChannelService](https://developer.android.com/reference/android/support/v4/app/NotificationCompatSideChannelService)
  - [NotificationManagerCompat](https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat)
  - [RemoteInput](https://developer.android.com/reference/android/support/v4/app/RemoteInput)
  - [RemoteInput.Builder](https://developer.android.com/reference/android/support/v4/app/RemoteInput.Builder)
  - [ServiceCompat](https://developer.android.com/reference/android/support/v4/app/ServiceCompat)
  - [ShareCompat](https://developer.android.com/reference/android/support/v4/app/ShareCompat)
  - [ShareCompat.IntentBuilder](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentBuilder)
  - [ShareCompat.IntentReader](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentReader)
  - [SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)
  - [TaskStackBuilder](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder)
-

  ## Exceptions

  - [Fragment.InstantiationException](https://developer.android.com/reference/android/support/v4/app/Fragment.InstantiationException)