CursorLoader
open classCursorLoader: AsyncTaskLoader<Cursor!>
| kotlin.Any | |||
| ↳ | android.content.Loader<D> | ||
| ↳ | android.content.AsyncTaskLoader<android.database.Cursor> | ||
| ↳ | android.content.CursorLoader | ||
A loader that queries the ContentResolver and returns a Cursor. This class implements the Loader protocol in a standard way for querying cursors, building on AsyncTaskLoader to perform the cursor query on a background thread so that it does not block the application's UI.
A CursorLoader must be built with the full information for the query to perform, either through the CursorLoader(android.content.Context,android.net.Uri,java.lang.String[],java.lang.String,java.lang.String[],java.lang.String) or creating an empty instance with CursorLoader(android.content.Context) and filling in the desired parameters with setUri(android.net.Uri), setSelection(java.lang.String), setSelectionArgs(java.lang.String[]), setSortOrder(java.lang.String), and setProjection(java.lang.String[]).
Summary
| Public constructors | |
|---|---|
CursorLoader(context: Context!)Creates an empty unspecified CursorLoader. |
|
CursorLoader(context: Context!, uri: Uri!, projection: Array<String!>!, selection: String!, selectionArgs: Array<String!>!, sortOrder: String!)Creates a fully-specified CursorLoader. |
|
| Public methods | |
|---|---|
| open Unit |
Called on the main thread to abort a load in progress. |
| open Unit |
deliverResult(cursor: Cursor!)Sends the result of the load to the registered listener. |
| open Unit |
dump(prefix: String!, fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!)Print the Loader's state into the given stream. |
| open Array<String!>! | |
| open String! | |
| open Array<String!>! | |
| open String! | |
| open Uri! |
getUri() |
| open Cursor! |
Called on a worker thread to perform the actual load and to return the result of the load operation. |
| open Unit |
onCanceled(cursor: Cursor!)Called if the task was canceled before it was completed. |
| open Unit |
setProjection(projection: Array<String!>!) |
| open Unit |
setSelection(selection: String!) |
| open Unit |
setSelectionArgs(selectionArgs: Array<String!>!) |
| open Unit |
setSortOrder(sortOrder: String!) |
| open Unit | |
| Protected methods | |
|---|---|
| open Unit |
onReset()Subclasses must implement this to take care of resetting their loader, as per |
| open Unit |
Starts an asynchronous load of the data. |
| open Unit |
Must be called from the UI thread |
| Inherited functions | |
|---|---|
Public constructors
CursorLoader
CursorLoader(context: Context!)
Creates an empty unspecified CursorLoader. You must follow this with calls to setUri(android.net.Uri), setSelection(java.lang.String), etc to specify the query to perform.
CursorLoader
CursorLoader(
context: Context!,
uri: Uri!,
projection: Array<String!>!,
selection: String!,
selectionArgs: Array<String!>!,
sortOrder: String!)
Creates a fully-specified CursorLoader. See ContentResolver.query() for documentation on the meaning of the parameters. These will be passed as-is to that call.
Public methods
cancelLoadInBackground
open funcancelLoadInBackground(): Unit
Deprecated: Deprecated in Java.
Called on the main thread to abort a load in progress. Override this method to abort the current invocation of loadInBackground that is running in the background on a worker thread. This method should do nothing if loadInBackground has not started running or if it has already finished.
deliverResult
open fundeliverResult(cursor: Cursor!): Unit
Deprecated: Deprecated in Java.
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.
| Parameters | |
|---|---|
data |
the result of the load |
dump
open fundump(
prefix: String!,
fd: FileDescriptor!,
writer: PrintWriter!,
args: Array<String!>!
): Unit
Deprecated: Deprecated in Java.
Print the Loader's state into the given stream.
| Parameters | |
|---|---|
prefix |
String!: Text to print at the front of each line. |
fd |
FileDescriptor!: The raw file descriptor that the dump is being sent to. |
writer |
PrintWriter!: A PrintWriter to which the dump is to be set. |
args |
Array<String!>!: Additional arguments to the dump request. |
getProjection
open fungetProjection(): Array<String!>!
Deprecated: Deprecated in Java.
getSelectionArgs
open fungetSelectionArgs(): Array<String!>!
Deprecated: Deprecated in Java.
loadInBackground
open funloadInBackground(): Cursor!
Deprecated: Deprecated in Java.
Called on a worker thread to perform the actual load and to return the result of the load operation. Implementations should not deliver the result directly, but should return them from this method, which will eventually end up calling deliverResult on the UI thread. If implementations need to process the results on the UI thread they may override deliverResult and do so there. To support cancellation, this method should periodically check the value of isLoadInBackgroundCanceled and terminate when it returns true. Subclasses may also override cancelLoadInBackground to interrupt the load directly instead of polling isLoadInBackgroundCanceled. When the load is canceled, this method may either return normally or throw OperationCanceledException. In either case, the Loader will call onCanceled to perform post-cancellation cleanup and to dispose of the result object, if any.
| Return | |
|---|---|
Cursor! |
The result of the load operation. |
| Exceptions | |
|---|---|
android.os.OperationCanceledException |
if the load is canceled during execution. |
onCanceled
open funonCanceled(cursor: Cursor!): Unit
Deprecated: Deprecated in Java.
Called if the task was canceled before it was completed. Gives the class a chance to clean up post-cancellation and to properly dispose of the result.
| Parameters | |
|---|---|
data |
The value that was returned by loadInBackground, or null if the task threw OperationCanceledException. |
setProjection
open funsetProjection(projection: Array<String!>!): Unit
Deprecated: Deprecated in Java.
setSelection
open funsetSelection(selection: String!): Unit
Deprecated: Deprecated in Java.
setSelectionArgs
open funsetSelectionArgs(selectionArgs: Array<String!>!): Unit
Deprecated: Deprecated in Java.
setSortOrder
open funsetSortOrder(sortOrder: String!): Unit
Deprecated: Deprecated in Java.
Protected methods
onReset
protected open funonReset(): Unit
Deprecated: Deprecated in Java.
Subclasses must implement this to take care of resetting their loader, as per reset(). This is not called by clients directly, but as a result of a call to reset(). This will always be called from the process's main thread.
onStartLoading
protected open funonStartLoading(): Unit
Deprecated: Deprecated in Java.
Starts an asynchronous load of the data. When the result is ready the callbacks will be called on the UI thread. If a previous load has been completed and is still valid the result may be passed to the callbacks immediately. Must be called from the UI thread
onStopLoading
protected open funonStopLoading(): Unit
Deprecated: Deprecated in Java.
Must be called from the UI thread