public abstract class AsyncQueryHandler extends Handler
ContentResolver
queries easier.Modifier and Type | Class and Description |
---|---|
protected static class |
AsyncQueryHandler.WorkerArgs |
protected class |
AsyncQueryHandler.WorkerHandler |
Handler.Callback
Constructor and Description |
---|
AsyncQueryHandler(ContentResolver cr) |
Modifier and Type | Method and Description |
---|---|
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.
|
dispatchMessage, dump, getLooper, getMessageName, getTraceName, hasCallbacks, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, runWithScissors, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
public AsyncQueryHandler(ContentResolver cr)
public void startQuery(int token, Object cookie, Uri uri, String[] projection, String selection, String[] selectionArgs, String orderBy)
onQueryComplete(int, java.lang.Object, android.database.Cursor)
is called.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)
uri
- The URI, using the content:// scheme, for the content to
retrieve.projection
- A list of which columns to return. Passing null will
return all columns, which is discouraged to prevent reading data
from storage that isn't going to be used.selection
- A filter declaring which rows to return, formatted as an
SQL WHERE clause (excluding the WHERE itself). Passing null will
return all rows for the given URI.selectionArgs
- You may include ?s in selection, which will be
replaced by the values from selectionArgs, in the order that they
appear in the selection. The values will be bound as Strings.orderBy
- How to order the rows, formatted as an SQL ORDER BY
clause (excluding the ORDER BY itself). Passing null will use the
default sort order, which may be unordered.public final void cancelOperation(int token)
token
- The token representing the operation to be canceled.
If multiple operations have the same token they will all be canceled.public final void startInsert(int token, Object cookie, Uri uri, ContentValues initialValues)
onInsertComplete(int, java.lang.Object, android.net.Uri)
is called.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.public final void startUpdate(int token, Object cookie, Uri uri, ContentValues values, String selection, String[] selectionArgs)
onUpdateComplete(int, java.lang.Object, int)
is called.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.public final void startDelete(int token, Object cookie, Uri uri, String selection, String[] selectionArgs)
onDeleteComplete(int, java.lang.Object, int)
is called.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.protected void onQueryComplete(int token, Object cookie, Cursor cursor)
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 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.protected void onInsertComplete(int token, Object cookie, Uri uri)
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.protected void onUpdateComplete(int token, Object cookie, int result)
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 operationprotected void onDeleteComplete(int token, Object cookie, int result)
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 operationpublic void handleMessage(Message msg)
Handler
handleMessage
in class Handler