android.support.v4.content
Class CursorLoader

java.lang.Object
  extended by android.support.v4.content.Loader<D>
      extended by android.support.v4.content.AsyncTaskLoader<android.database.Cursor>
          extended by android.support.v4.content.CursorLoader

public class CursorLoader
extends AsyncTaskLoader<android.database.Cursor>

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.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.support.v4.content.Loader
Loader.ForceLoadContentObserver, Loader.OnLoadCompleteListener<D>
 
Constructor Summary
CursorLoader(android.content.Context context)
          Creates an empty unspecified CursorLoader.
CursorLoader(android.content.Context context, android.net.Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
          Creates a fully-specified CursorLoader.
 
Method Summary
 void deliverResult(android.database.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()
           
 android.net.Uri getUri()
           
 android.database.Cursor loadInBackground()
           
 void onCanceled(android.database.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(android.net.Uri uri)
           
 
Methods inherited from class android.support.v4.content.AsyncTaskLoader
cancelLoad, onForceLoad, onLoadInBackground, setUpdateThrottle, waitForLoader
 
Methods inherited from class android.support.v4.content.Loader
abandon, dataToString, forceLoad, getContext, getId, isAbandoned, isReset, isStarted, onAbandon, onContentChanged, registerListener, reset, startLoading, stopLoading, takeContentChanged, toString, unregisterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CursorLoader

public CursorLoader(android.content.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.


CursorLoader

public CursorLoader(android.content.Context context,
                    android.net.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.

Method Detail

loadInBackground

public android.database.Cursor loadInBackground()
Specified by:
loadInBackground in class AsyncTaskLoader<android.database.Cursor>

deliverResult

public void deliverResult(android.database.Cursor cursor)
Description copied from class: Loader
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.

Overrides:
deliverResult in class Loader<android.database.Cursor>
Parameters:
cursor - the result of the load

onStartLoading

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

Overrides:
onStartLoading in class Loader<android.database.Cursor>

onStopLoading

protected void onStopLoading()
Must be called from the UI thread

Overrides:
onStopLoading in class Loader<android.database.Cursor>

onCanceled

public void onCanceled(android.database.Cursor cursor)
Description copied from class: AsyncTaskLoader
Called if the task was canceled before it was completed. Gives the class a chance to properly dispose of the result.

Overrides:
onCanceled in class AsyncTaskLoader<android.database.Cursor>

onReset

protected void onReset()
Description copied from class: Loader
Subclasses must implement this to take care of resetting their loader, as per 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.

Overrides:
onReset in class Loader<android.database.Cursor>

getUri

public android.net.Uri getUri()

setUri

public void setUri(android.net.Uri uri)

getProjection

public String[] getProjection()

setProjection

public void setProjection(String[] projection)

getSelection

public String getSelection()

setSelection

public void setSelection(String selection)

getSelectionArgs

public String[] getSelectionArgs()

setSelectionArgs

public void setSelectionArgs(String[] selectionArgs)

getSortOrder

public String getSortOrder()

setSortOrder

public void setSortOrder(String sortOrder)

dump

public void dump(String prefix,
                 FileDescriptor fd,
                 PrintWriter writer,
                 String[] args)
Description copied from class: Loader
Print the Loader's state into the given stream.

Overrides:
dump in class AsyncTaskLoader<android.database.Cursor>
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.


Copyright © 2013 Marek Kedzierski. All Rights Reserved.