Android APIs
public class

CursorLoader

extends AsyncTaskLoader<D>
java.lang.Object
   ↳ android.support.v4.content.Loader<D>
     ↳ android.support.v4.content.AsyncTaskLoader<D>
       ↳ android.support.v4.content.CursorLoader

Class Overview

Static library support version of the framework's CursorLoader. 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.

Summary

Public Constructors
CursorLoader(Context context)
Creates an empty unspecified CursorLoader.
CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
Creates a fully-specified CursorLoader.
Public Methods
void deliverResult(Cursor cursor)
Sends the result of the load to the registered listener.
void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
Print the Loader's state into the given stream.
String[] getProjection()
String getSelection()
String[] getSelectionArgs()
String getSortOrder()
Uri getUri()
Cursor loadInBackground()
void onCanceled(Cursor cursor)
Called if the task was canceled before it was completed.
void setProjection(String[] projection)
void setSelection(String selection)
void setSelectionArgs(String[] selectionArgs)
void setSortOrder(String sortOrder)
void setUri(Uri uri)
Protected Methods
void onReset()
Subclasses must implement this to take care of resetting their loader, as per reset().
void onStartLoading()
Starts an asynchronous load of the contacts list data.
void onStopLoading()
Must be called from the UI thread
[Expand]
Inherited Methods
From class android.support.v4.content.AsyncTaskLoader
From class android.support.v4.content.Loader
From class java.lang.Object

Public Constructors

public CursorLoader (Context context)

Creates an empty unspecified CursorLoader. You must follow this with calls to setUri(Uri), setSelection(String), etc to specify the query to perform.

public CursorLoader (Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)

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

public void deliverResult (Cursor cursor)

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
cursor the result of the load

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

Print the Loader's state into the given stream.

Parameters
prefix Text to print at the front of each line.
fd The raw file descriptor that the dump is being sent to.
writer A PrintWriter to which the dump is to be set.
args Additional arguments to the dump request.

public String[] getProjection ()

public String getSelection ()

public String[] getSelectionArgs ()

public String getSortOrder ()

public Uri getUri ()

public Cursor loadInBackground ()

public void onCanceled (Cursor cursor)

Called if the task was canceled before it was completed. Gives the class a chance to properly dispose of the result.

public void setProjection (String[] projection)

public void setSelection (String selection)

public void setSelectionArgs (String[] selectionArgs)

public void setSortOrder (String sortOrder)

public void setUri (Uri uri)

Protected Methods

protected void onReset ()

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.

protected void onStartLoading ()

Starts an asynchronous load of the contacts list 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

protected void onStopLoading ()

Must be called from the UI thread