# Loader

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)  
Summary:[Nested Classes](https://developer.android.com/reference/android/content/Loader#nestedclasses)\|[Ctors](https://developer.android.com/reference/android/content/Loader#pubctors)\|[Methods](https://developer.android.com/reference/android/content/Loader#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/content/Loader#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/content/Loader#inhmethods)  

# Loader

*** ** * ** ***

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

`
public


class
Loader
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.Loader\<D\> |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [AsyncTaskLoader](https://developer.android.com/reference/android/content/AsyncTaskLoader)\<D\> |-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AsyncTaskLoader](https://developer.android.com/reference/android/content/AsyncTaskLoader)\<D\> | *This class was deprecated in API level 28. Use the[Support Library](https://developer.android.com/tools/extras/support-library)[AsyncTaskLoader](https://developer.android.com/reference/androidx/loader/content/AsyncTaskLoader.html)* | |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [CursorLoader](https://developer.android.com/reference/android/content/CursorLoader) |--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [CursorLoader](https://developer.android.com/reference/android/content/CursorLoader) | *This class was deprecated in API level 28. Use the[Support Library](https://developer.android.com/tools/extras/support-library)[CursorLoader](https://developer.android.com/reference/androidx/loader/content/CursorLoader.html)* | |

<br />

*** ** * ** ***

<br />

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

A class that performs asynchronous loading of data. While Loaders are active they should monitor the source of their data and deliver new results when the contents change. See[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)for more detail.

**Note on threading:** Clients of loaders should as a rule perform any calls on to a Loader from the main thread of their process (that is, the thread the Activity callbacks and other things occur on). Subclasses of Loader (such as[AsyncTaskLoader](https://developer.android.com/reference/android/content/AsyncTaskLoader)) will often perform their work in a separate thread, but when delivering their results this too should be done on the main thread.

Subclasses generally must implement at least[onStartLoading()](https://developer.android.com/reference/android/content/Loader#onStartLoading()),[onStopLoading()](https://developer.android.com/reference/android/content/Loader#onStopLoading()),[onForceLoad()](https://developer.android.com/reference/android/content/Loader#onForceLoad()), and[onReset()](https://developer.android.com/reference/android/content/Loader#onReset()).

Most implementations should not derive directly from this class, but instead inherit from[AsyncTaskLoader](https://developer.android.com/reference/android/content/AsyncTaskLoader).  

### Developer Guides

For more information about using loaders, read the[Loaders](https://developer.android.com/guide/components/loaders)developer guide.

<br />

## Summary

|                                                                                                                                                        ### Nested classes                                                                                                                                                         ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class`     | [Loader.ForceLoadContentObserver](https://developer.android.com/reference/android/content/Loader.ForceLoadContentObserver) *This class was deprecated in API level 28. Use[Loader.ForceLoadContentObserver](https://developer.android.com/reference/androidx/loader/content/Loader.ForceLoadContentObserver.html)*  |
| ` interface` | [Loader.OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)`<D>` *This interface was deprecated in API level 28. Use[Loader.OnLoadCanceledListener](https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCanceledListener.html)* |
| ` interface` | [Loader.OnLoadCompleteListener](https://developer.android.com/reference/android/content/Loader.OnLoadCompleteListener)`<D>` *This interface was deprecated in API level 28. Use[Loader.OnLoadCompleteListener](https://developer.android.com/reference/androidx/loader/content/Loader.OnLoadCompleteListener.html)* |

|                                                                                                                       ### Public constructors                                                                                                                        ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Loader](https://developer.android.com/reference/android/content/Loader#Loader(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Stores away the application context associated with context. |

|                                                                                                                                                                                                                                                                                                                            ### Public methods                                                                                                                                                                                                                                                                                                                             ||
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                       | ` `[abandon](https://developer.android.com/reference/android/content/Loader#abandon())`() ` This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when restarting a Loader.                                                                                                                                                                                                                                                                                                                      |
| ` boolean`                                                                    | ` `[cancelLoad](https://developer.android.com/reference/android/content/Loader#cancelLoad())`() ` Attempt to cancel the current load task.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                       | ` `[commitContentChanged](https://developer.android.com/reference/android/content/Loader#commitContentChanged())`() ` Commit that you have actually fully processed a content change that was returned by[takeContentChanged()](https://developer.android.com/reference/android/content/Loader#takeContentChanged()).                                                                                                                                                                                                                                                                      |
| ` `[String](https://developer.android.com/reference/java/lang/String)         | ` `[dataToString](https://developer.android.com/reference/android/content/Loader#dataToString(D))`(D data) ` For debugging, converts an instance of the Loader's data class to a string that can be printed.                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                       | ` `[deliverCancellation](https://developer.android.com/reference/android/content/Loader#deliverCancellation())`() ` Informs the registered[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)that the load has been canceled.                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                       | ` `[deliverResult](https://developer.android.com/reference/android/content/Loader#deliverResult(D))`(D data) ` Sends the result of the load to the registered listener.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                       | ` `[dump](https://developer.android.com/reference/android/content/Loader#dump(java.lang.String,%20java.io.FileDescriptor,%20java.io.PrintWriter,%20java.lang.String[]))`(`[String](https://developer.android.com/reference/java/lang/String)` prefix, `[FileDescriptor](https://developer.android.com/reference/java/io/FileDescriptor)` fd, `[PrintWriter](https://developer.android.com/reference/java/io/PrintWriter)` writer, `[String[]](https://developer.android.com/reference/java/lang/String)` args) ` Print the Loader's state into the given stream.                           |
| ` void`                                                                       | ` `[forceLoad](https://developer.android.com/reference/android/content/Loader#forceLoad())`() ` Force an asynchronous load.                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[Context](https://developer.android.com/reference/android/content/Context) | ` `[getContext](https://developer.android.com/reference/android/content/Loader#getContext())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` int`                                                                        | ` `[getId](https://developer.android.com/reference/android/content/Loader#getId())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` boolean`                                                                    | ` `[isAbandoned](https://developer.android.com/reference/android/content/Loader#isAbandoned())`() ` Return whether this loader has been abandoned.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                    | ` `[isReset](https://developer.android.com/reference/android/content/Loader#isReset())`() ` Return whether this load has been reset.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` boolean`                                                                    | ` `[isStarted](https://developer.android.com/reference/android/content/Loader#isStarted())`() ` Return whether this load has been started.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                       | ` `[onContentChanged](https://developer.android.com/reference/android/content/Loader#onContentChanged())`() ` Called when[ForceLoadContentObserver](https://developer.android.com/reference/android/content/Loader.ForceLoadContentObserver)detects a change.                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                       | ` `[registerListener](https://developer.android.com/reference/android/content/Loader#registerListener(int,%20android.content.Loader.OnLoadCompleteListener<D>))`(int id, `[OnLoadCompleteListener](https://developer.android.com/reference/android/content/Loader.OnLoadCompleteListener)`<D> listener) ` Registers a class that will receive callbacks when a load is complete.                                                                                                                                                                                                           |
| ` void`                                                                       | ` `[registerOnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader#registerOnLoadCanceledListener(android.content.Loader.OnLoadCanceledListener<D>))`(`[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)`<D> listener) ` Registers a listener that will receive callbacks when a load is canceled.                                                                                                                                                                                           |
| ` void`                                                                       | ` `[reset](https://developer.android.com/reference/android/content/Loader#reset())`() ` This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when destroying a Loader.                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                       | ` `[rollbackContentChanged](https://developer.android.com/reference/android/content/Loader#rollbackContentChanged())`() ` Report that you have abandoned the processing of a content change that was returned by[takeContentChanged()](https://developer.android.com/reference/android/content/Loader#takeContentChanged())and would like to rollback to the state where there is again a pending content change.                                                                                                                                                                          |
| ` final void`                                                                 | ` `[startLoading](https://developer.android.com/reference/android/content/Loader#startLoading())`() ` This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when the associated fragment/activity is being started.                                                                                                                                                                                                                                                                              |
| ` void`                                                                       | ` `[stopLoading](https://developer.android.com/reference/android/content/Loader#stopLoading())`() ` This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when the associated fragment/activity is being stopped.                                                                                                                                                                                                                                                                                |
| ` boolean`                                                                    | ` `[takeContentChanged](https://developer.android.com/reference/android/content/Loader#takeContentChanged())`() ` Take the current flag indicating whether the loader's content had changed while it was stopped.                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[String](https://developer.android.com/reference/java/lang/String)         | ` `[toString](https://developer.android.com/reference/android/content/Loader#toString())`() ` Returns a string representation of the object.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                       | ` `[unregisterListener](https://developer.android.com/reference/android/content/Loader#unregisterListener(android.content.Loader.OnLoadCompleteListener<D>))`(`[OnLoadCompleteListener](https://developer.android.com/reference/android/content/Loader.OnLoadCompleteListener)`<D> listener) ` Remove a listener that was previously added with[registerListener(int, OnLoadCompleteListener)](https://developer.android.com/reference/android/content/Loader#registerListener(int,%20android.content.Loader.OnLoadCompleteListener<D>)).                                                  |
| ` void`                                                                       | ` `[unregisterOnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader#unregisterOnLoadCanceledListener(android.content.Loader.OnLoadCanceledListener<D>))`(`[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)`<D> listener) ` Unregisters a listener that was previously added with[registerOnLoadCanceledListener(OnLoadCanceledListener)](https://developer.android.com/reference/android/content/Loader#registerOnLoadCanceledListener(android.content.Loader.OnLoadCanceledListener<D>)). |

|                                                                                                                                      ### Protected methods                                                                                                                                      ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[onAbandon](https://developer.android.com/reference/android/content/Loader#onAbandon())`() ` Subclasses implement this to take care of being abandoned.                                                                                                                          |
| ` boolean` | ` `[onCancelLoad](https://developer.android.com/reference/android/content/Loader#onCancelLoad())`() ` Subclasses must implement this to take care of requests to[cancelLoad()](https://developer.android.com/reference/android/content/Loader#cancelLoad()).                        |
| ` void`    | ` `[onForceLoad](https://developer.android.com/reference/android/content/Loader#onForceLoad())`() ` Subclasses must implement this to take care of requests to[forceLoad()](https://developer.android.com/reference/android/content/Loader#forceLoad()).                            |
| ` void`    | ` `[onReset](https://developer.android.com/reference/android/content/Loader#onReset())`() ` Subclasses must implement this to take care of resetting their loader, as per[reset()](https://developer.android.com/reference/android/content/Loader#reset()).                         |
| ` void`    | ` `[onStartLoading](https://developer.android.com/reference/android/content/Loader#onStartLoading())`() ` Subclasses must implement this to take care of loading their data, as per[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading()). |
| ` void`    | ` `[onStopLoading](https://developer.android.com/reference/android/content/Loader#onStopLoading())`() ` Subclasses must implement this to take care of stopping their loader, as per[stopLoading()](https://developer.android.com/reference/android/content/Loader#stopLoading()).  |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Loader

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

```
public Loader (Context context)
```

Stores away the application context associated with context. Since Loaders can be used across multiple activities it's dangerous to store the context directly; always use[getContext()](https://developer.android.com/reference/android/content/Loader#getContext())to retrieve the Loader's Context, don't use the constructor argument directly. The Context returned by[getContext()](https://developer.android.com/reference/android/content/Loader#getContext())is safe to use across Activity instances.

<br />

|                               Parameters                               ||
|-----------|-------------------------------------------------------------|
| `context` | `Context`: used to retrieve the application context. <br /> |

## Public methods

### abandon

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

```
public void abandon ()
```

This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when restarting a Loader. When using a Loader with[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager), you*must not* call this method yourself, or you will conflict with its management of the Loader. Tell the Loader that it is being abandoned. This is called prior to[reset()](https://developer.android.com/reference/android/content/Loader#reset())to have it retain its current data but not report any new data.

<br />

### cancelLoad

Added in[API level 16](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)  

```
public boolean cancelLoad ()
```

Attempt to cancel the current load task. Must be called on the main thread of the process.

Cancellation is not an immediate operation, since the load is performed in a background thread. If there is currently a load in progress, this method requests that the load be canceled, and notes this is the case; once the background thread has completed its work its remaining state will be cleared. If another load request comes in during this time, it will be held until the canceled load is complete.

<br />

|                                                                                                                                                                                                                                        Returns                                                                                                                                                                                                                                        ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Returnsfalseif the task could not be canceled, typically because it has already completed normally, or because[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())hasn't been called; returnstrueotherwise. Whentrueis returned, the task is still running and the[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)will be called when the task completes. <br /> |

### commitContentChanged

Added in[API level 18](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)  

```
public void commitContentChanged ()
```

Commit that you have actually fully processed a content change that was returned by[takeContentChanged()](https://developer.android.com/reference/android/content/Loader#takeContentChanged()). This is for use with[rollbackContentChanged()](https://developer.android.com/reference/android/content/Loader#rollbackContentChanged())to handle situations where a load is cancelled. Call this when you have completely processed a load without it being cancelled.

<br />

### dataToString

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

```
public String dataToString (D data)
```

For debugging, converts an instance of the Loader's data class to a string that can be printed. Must handle a null data.

<br />

|     Parameters     ||
|--------|------------|
| `data` | `D` <br /> |

|                                  Returns                                   ||
|--------------------------------------------------------------------|--------|
| [String](https://developer.android.com/reference/java/lang/String) | <br /> |

### deliverCancellation

Added in[API level 16](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)  

```
public void deliverCancellation ()
```

Informs the registered[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)that the load has been canceled. Should only be called by subclasses. Must be called from the process's main thread.

<br />

### deliverResult

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

```
public void deliverResult (D data)
```

Sends the result of the load to the registered listener. Should only be called by subclasses. Must be called from the process's main thread.

<br />

|                 Parameters                 ||
|--------|------------------------------------|
| `data` | `D`: the result of the load <br /> |

### dump

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

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

Print the Loader'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 />                       |

### forceLoad

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

```
public void forceLoad ()
```

Force an asynchronous load. Unlike[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())this will ignore a previously loaded data set and load a new one. This simply calls through to the implementation's[onForceLoad()](https://developer.android.com/reference/android/content/Loader#onForceLoad()). You generally should only call this when the loader is started -- that is,[isStarted()](https://developer.android.com/reference/android/content/Loader#isStarted())returns true.

Must be called from the process's main thread.

<br />

### getContext

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

```
public Context getContext ()
```

<br />

<br />

|                                                                             Returns                                                                             ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [Context](https://developer.android.com/reference/android/content/Context) | an application context retrieved from the Context passed to the constructor. <br /> |

### getId

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

```
public int getId ()
```

<br />

<br />

|               Returns               ||
|-------|------------------------------|
| `int` | the ID of this loader <br /> |

### isAbandoned

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

```
public boolean isAbandoned ()
```

Return whether this loader has been abandoned. In this state, the loader*must not* report any new data, and*must*keep its last reported data valid until it is finally reset.

<br />

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

### isReset

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

```
public boolean isReset ()
```

Return whether this load has been reset. That is, either the loader has not yet been started for the first time, or its[reset()](https://developer.android.com/reference/android/content/Loader#reset())has been called.

<br />

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

### isStarted

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

```
public boolean isStarted ()
```

Return whether this load has been started. That is, its[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())has been called and no calls to[stopLoading()](https://developer.android.com/reference/android/content/Loader#stopLoading())or[reset()](https://developer.android.com/reference/android/content/Loader#reset())have yet been made.

<br />

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

### onContentChanged

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

```
public void onContentChanged ()
```

Called when[ForceLoadContentObserver](https://developer.android.com/reference/android/content/Loader.ForceLoadContentObserver)detects a change. The default implementation checks to see if the loader is currently started; if so, it simply calls[forceLoad()](https://developer.android.com/reference/android/content/Loader#forceLoad()); otherwise, it sets a flag so that[takeContentChanged()](https://developer.android.com/reference/android/content/Loader#takeContentChanged())returns true.

Must be called from the process's main thread.

<br />

### registerListener

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

```
public void registerListener (int id, 
                OnLoadCompleteListener<D> listener)
```

Registers a class that will receive callbacks when a load is complete. The callback will be called on the process's main thread so it's safe to pass the results to widgets.

Must be called from the process's main thread.

<br />

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

### registerOnLoadCanceledListener

Added in[API level 16](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)  

```
public void registerOnLoadCanceledListener (OnLoadCanceledListener<D> listener)
```

Registers a listener that will receive callbacks when a load is canceled. The callback will be called on the process's main thread so it's safe to pass the results to widgets. Must be called from the process's main thread.

<br />

|                               Parameters                               ||
|------------|------------------------------------------------------------|
| `listener` | `OnLoadCanceledListener`: The listener to register. <br /> |

### reset

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

```
public void reset ()
```

This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when destroying a Loader. When using a Loader with[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager), you*must not* call this method yourself, or you will conflict with its management of the Loader. Resets the state of the Loader. The Loader should at this point free all of its resources, since it may never be called again; however, its[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())may later be called at which point it must be able to start running again.

This updates the Loader's internal state so that[isStarted()](https://developer.android.com/reference/android/content/Loader#isStarted())and[isReset()](https://developer.android.com/reference/android/content/Loader#isReset())will return the correct values, and then calls the implementation's[onReset()](https://developer.android.com/reference/android/content/Loader#onReset()).

Must be called from the process's main thread.

<br />

### rollbackContentChanged

Added in[API level 18](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)  

```
public void rollbackContentChanged ()
```

Report that you have abandoned the processing of a content change that was returned by[takeContentChanged()](https://developer.android.com/reference/android/content/Loader#takeContentChanged())and would like to rollback to the state where there is again a pending content change. This is to handle the case where a data load due to a content change has been canceled before its data was delivered back to the loader.

<br />

### startLoading

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

```
public final void startLoading ()
```

This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when the associated fragment/activity is being started. When using a Loader with[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager), you*must not* call this method yourself, or you will conflict with its management of the Loader. Starts an asynchronous load of the Loader's data. When the result is ready the callbacks will be called on the process's main thread. If a previous load has been completed and is still valid the result may be passed to the callbacks immediately. The loader will monitor the source of the data set and may deliver future callbacks if the source changes. Calling[stopLoading()](https://developer.android.com/reference/android/content/Loader#stopLoading())will stop the delivery of callbacks.

This updates the Loader's internal state so that[isStarted()](https://developer.android.com/reference/android/content/Loader#isStarted())and[isReset()](https://developer.android.com/reference/android/content/Loader#isReset())will return the correct values, and then calls the implementation's[onStartLoading()](https://developer.android.com/reference/android/content/Loader#onStartLoading()).

Must be called from the process's main thread.

<br />

### stopLoading

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

```
public void stopLoading ()
```

This function will normally be called for you automatically by[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager)when the associated fragment/activity is being stopped. When using a Loader with[LoaderManager](https://developer.android.com/reference/android/app/LoaderManager), you*must not*call this method yourself, or you will conflict with its management of the Loader.

Stops delivery of updates until the next time[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())is called. Implementations should*not* invalidate their data at this point -- clients are still free to use the last data the loader reported. They will, however, typically stop reporting new data if the data changes; they can still monitor for changes, but must not report them to the client until and if[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())is later called.

This updates the Loader's internal state so that[isStarted()](https://developer.android.com/reference/android/content/Loader#isStarted())will return the correct value, and then calls the implementation's[onStopLoading()](https://developer.android.com/reference/android/content/Loader#onStopLoading()).

Must be called from the process's main thread.

<br />

### takeContentChanged

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

```
public boolean takeContentChanged ()
```

Take the current flag indicating whether the loader's content had changed while it was stopped. If it had, true is returned and the flag is cleared.

<br />

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

### toString

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

```
public String toString ()
```

Returns a string representation of the object.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

### unregisterListener

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

```
public void unregisterListener (OnLoadCompleteListener<D> listener)
```

Remove a listener that was previously added with[registerListener(int, OnLoadCompleteListener)](https://developer.android.com/reference/android/content/Loader#registerListener(int,%20android.content.Loader.OnLoadCompleteListener<D>)). Must be called from the process's main thread.

<br />

|                 Parameters                  ||
|------------|---------------------------------|
| `listener` | `OnLoadCompleteListener` <br /> |

### unregisterOnLoadCanceledListener

Added in[API level 16](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)  

```
public void unregisterOnLoadCanceledListener (OnLoadCanceledListener<D> listener)
```

Unregisters a listener that was previously added with[registerOnLoadCanceledListener(OnLoadCanceledListener)](https://developer.android.com/reference/android/content/Loader#registerOnLoadCanceledListener(android.content.Loader.OnLoadCanceledListener<D>)). Must be called from the process's main thread.

<br />

|                                Parameters                                ||
|------------|--------------------------------------------------------------|
| `listener` | `OnLoadCanceledListener`: The listener to unregister. <br /> |

## Protected methods

### onAbandon

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

```
protected void onAbandon ()
```

Subclasses implement this to take care of being abandoned. This is an optional intermediate state prior to[onReset()](https://developer.android.com/reference/android/content/Loader#onReset())-- it means that the client is no longer interested in any new data from the loader, so the loader must not report any further updates. However, the loader*must* keep its last reported data valid until the final[onReset()](https://developer.android.com/reference/android/content/Loader#onReset())happens. You can retrieve the current abandoned state with[isAbandoned()](https://developer.android.com/reference/android/content/Loader#isAbandoned()).

<br />

### onCancelLoad

Added in[API level 16](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)  

```
protected boolean onCancelLoad ()
```

Subclasses must implement this to take care of requests to[cancelLoad()](https://developer.android.com/reference/android/content/Loader#cancelLoad()). This will always be called from the process's main thread.

<br />

|                                                                                                                                                                                                                                        Returns                                                                                                                                                                                                                                        ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | Returnsfalseif the task could not be canceled, typically because it has already completed normally, or because[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading())hasn't been called; returnstrueotherwise. Whentrueis returned, the task is still running and the[OnLoadCanceledListener](https://developer.android.com/reference/android/content/Loader.OnLoadCanceledListener)will be called when the task completes. <br /> |

### onForceLoad

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

```
protected void onForceLoad ()
```

Subclasses must implement this to take care of requests to[forceLoad()](https://developer.android.com/reference/android/content/Loader#forceLoad()). This will always be called from the process's main thread.

<br />

### onReset

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

```
protected void onReset ()
```

Subclasses must implement this to take care of resetting their loader, as per[reset()](https://developer.android.com/reference/android/content/Loader#reset()). This is not called by clients directly, but as a result of a call to[reset()](https://developer.android.com/reference/android/content/Loader#reset()). This will always be called from the process's main thread.

<br />

### onStartLoading

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

```
protected void onStartLoading ()
```

Subclasses must implement this to take care of loading their data, as per[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading()). This is not called by clients directly, but as a result of a call to[startLoading()](https://developer.android.com/reference/android/content/Loader#startLoading()).

<br />

### onStopLoading

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

```
protected void onStopLoading ()
```

Subclasses must implement this to take care of stopping their loader, as per[stopLoading()](https://developer.android.com/reference/android/content/Loader#stopLoading()). This is not called by clients directly, but as a result of a call to[stopLoading()](https://developer.android.com/reference/android/content/Loader#stopLoading()). This will always be called from the process's main thread.

<br />