public class CursorLoader extends AsyncTaskLoader<Cursor>
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.Loader.ForceLoadContentObserver, Loader.OnLoadCompleteListener<D>
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
onReset()
Subclasses must implement this to take care of resetting their loader,
as per
Loader.reset() . |
protected void |
onStartLoading()
Starts an asynchronous load of the contacts list data.
|
protected void |
onStopLoading()
Must be called from the UI thread
|
void |
setProjection(String[] projection) |
void |
setSelection(String selection) |
void |
setSelectionArgs(String[] selectionArgs) |
void |
setSortOrder(String sortOrder) |
void |
setUri(Uri uri) |
cancelLoad, onForceLoad, onLoadInBackground, setUpdateThrottle, waitForLoader
abandon, dataToString, forceLoad, getContext, getId, isAbandoned, isReset, isStarted, onAbandon, onContentChanged, registerListener, reset, startLoading, stopLoading, takeContentChanged, toString, unregisterListener
public CursorLoader(Context context)
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)
ContentResolver.query()
for documentation on the meaning of the
parameters. These will be passed as-is to that call.public Cursor loadInBackground()
loadInBackground
in class AsyncTaskLoader<Cursor>
public void deliverResult(Cursor cursor)
Loader
deliverResult
in class Loader<Cursor>
cursor
- the result of the loadprotected void onStartLoading()
onStartLoading
in class Loader<Cursor>
protected void onStopLoading()
onStopLoading
in class Loader<Cursor>
public void onCanceled(Cursor cursor)
AsyncTaskLoader
onCanceled
in class AsyncTaskLoader<Cursor>
protected void onReset()
Loader
Loader.reset()
. This is not called by clients directly,
but as a result of a call to Loader.reset()
.
This will always be called from the process's main thread.public Uri getUri()
public void setUri(Uri uri)
public String[] getProjection()
public void setProjection(String[] projection)
public String getSelection()
public void setSelection(String selection)
public String[] getSelectionArgs()
public void setSelectionArgs(String[] selectionArgs)
public String getSortOrder()
public void setSortOrder(String sortOrder)
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
Loader
dump
in class AsyncTaskLoader<Cursor>
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.