Build 1.0_r1(from source)

android.content
Class AsyncQueryHandler

java.lang.Object
  extended by android.os.Handler
      extended by android.content.AsyncQueryHandler

public abstract class AsyncQueryHandler
extends Handler

A helper class to help make handling asynchronous ContentResolver queries easier.


Nested Class Summary
protected static class AsyncQueryHandler.WorkerArgs
           
protected  class AsyncQueryHandler.WorkerHandler
           
 
Field Summary
(package private)  ContentResolver mResolver
           
 
Constructor Summary
AsyncQueryHandler(ContentResolver cr)
           
 
Method Summary
 void cancelOperation(int token)
          Attempts to cancel operation that has not already started.
protected  Handler createHandler(Looper looper)
           
 void handleMessage(Message msg)
          Subclasses must implement this to receive messages.
protected  void onDeleteComplete(int token, Object cookie, int result)
          Called when an asynchronous delete is completed.
protected  void onInsertComplete(int token, Object cookie, Uri uri)
          Called when an asynchronous insert is completed.
protected  void onQueryComplete(int token, Object cookie, Cursor cursor)
          Called when an asynchronous query is completed.
protected  void onUpdateComplete(int token, Object cookie, int result)
          Called when an asynchronous update is completed.
 void startDelete(int token, Object cookie, Uri uri, String selection, String[] selectionArgs)
          This method begins an asynchronous delete.
 void startInsert(int token, Object cookie, Uri uri, ContentValues initialValues)
          This method begins an asynchronous insert.
 void startQuery(int token, Object cookie, Uri uri, String[] projection, String selection, String[] selectionArgs, String orderBy)
          This method begins an asynchronous query.
 void startUpdate(int token, Object cookie, Uri uri, ContentValues values, String selection, String[] selectionArgs)
          This method begins an asynchronous update.
 
Methods inherited from class android.os.Handler
dispatchMessage, dump, getLooper, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mResolver

ContentResolver mResolver
Constructor Detail

AsyncQueryHandler

public AsyncQueryHandler(ContentResolver cr)
Method Detail

createHandler

protected Handler createHandler(Looper looper)

startQuery

public void startQuery(int token,
                       Object cookie,
                       Uri uri,
                       String[] projection,
                       String selection,
                       String[] selectionArgs,
                       String orderBy)
This method begins an asynchronous query. When the query is done onQueryComplete(int, java.lang.Object, android.database.Cursor) is called.

Parameters:
token - A token passed into onQueryComplete(int, java.lang.Object, android.database.Cursor) to identify the query.
cookie - An object that gets passed into onQueryComplete(int, java.lang.Object, android.database.Cursor)

cancelOperation

public final void cancelOperation(int token)
Attempts to cancel operation that has not already started. Note that there is no guarantee that the operation will be canceled. They still may result in a call to on[Query/Insert/Update/Delete]Complete after this call has completed.

Parameters:
token - The token representing the operation to be canceled. If multiple operations have the same token they will all be canceled.

startInsert

public final void startInsert(int token,
                              Object cookie,
                              Uri uri,
                              ContentValues initialValues)
This method begins an asynchronous insert. When the insert operation is done onInsertComplete(int, java.lang.Object, android.net.Uri) is called.

Parameters:
token - A token passed into onInsertComplete(int, java.lang.Object, android.net.Uri) to identify the insert operation.
cookie - An object that gets passed into onInsertComplete(int, java.lang.Object, android.net.Uri)
uri - the Uri passed to the insert operation.
initialValues - the ContentValues parameter passed to the insert operation.

startUpdate

public final void startUpdate(int token,
                              Object cookie,
                              Uri uri,
                              ContentValues values,
                              String selection,
                              String[] selectionArgs)
This method begins an asynchronous update. When the update operation is done onUpdateComplete(int, java.lang.Object, int) is called.

Parameters:
token - A token passed into onUpdateComplete(int, java.lang.Object, int) to identify the update operation.
cookie - An object that gets passed into onUpdateComplete(int, java.lang.Object, int)
uri - the Uri passed to the update operation.
values - the ContentValues parameter passed to the update operation.

startDelete

public final void startDelete(int token,
                              Object cookie,
                              Uri uri,
                              String selection,
                              String[] selectionArgs)
This method begins an asynchronous delete. When the delete operation is done onDeleteComplete(int, java.lang.Object, int) is called.

Parameters:
token - A token passed into onDeleteComplete(int, java.lang.Object, int) to identify the delete operation.
cookie - An object that gets passed into onDeleteComplete(int, java.lang.Object, int)
uri - the Uri passed to the delete operation.
selection - the where clause.

onQueryComplete

protected void onQueryComplete(int token,
                               Object cookie,
                               Cursor cursor)
Called when an asynchronous query is completed.

Parameters:
token - the token to identify the query, passed in from startQuery(int, java.lang.Object, android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String).
cookie - the cookie object that's passed in from startQuery(int, java.lang.Object, android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String).
cursor - The cursor holding the results from the query.

onInsertComplete

protected void onInsertComplete(int token,
                                Object cookie,
                                Uri uri)
Called when an asynchronous insert is completed.

Parameters:
token - the token to identify the query, passed in from startInsert(int, java.lang.Object, android.net.Uri, android.content.ContentValues).
cookie - the cookie object that's passed in from startInsert(int, java.lang.Object, android.net.Uri, android.content.ContentValues).
uri - the uri returned from the insert operation.

onUpdateComplete

protected void onUpdateComplete(int token,
                                Object cookie,
                                int result)
Called when an asynchronous update is completed.

Parameters:
token - the token to identify the query, passed in from startUpdate(int, java.lang.Object, android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]).
cookie - the cookie object that's passed in from startUpdate(int, java.lang.Object, android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[]).
result - the result returned from the update operation

onDeleteComplete

protected void onDeleteComplete(int token,
                                Object cookie,
                                int result)
Called when an asynchronous delete is completed.

Parameters:
token - the token to identify the query, passed in from startDelete(int, java.lang.Object, android.net.Uri, java.lang.String, java.lang.String[]).
cookie - the cookie object that's passed in from startDelete(int, java.lang.Object, android.net.Uri, java.lang.String, java.lang.String[]).
result - the result returned from the delete operation

handleMessage

public void handleMessage(Message msg)
Description copied from class: Handler
Subclasses must implement this to receive messages.

Overrides:
handleMessage in class Handler

Build 1.0_r1(from source)

Please submit a feedback, bug or feature