Most visited

Recently visited

Added in API level 1

AsyncQueryHandler

public abstract class AsyncQueryHandler
extends Handler

java.lang.Object
   ↳ android.os.Handler
     ↳ android.content.AsyncQueryHandler


一个帮助器类,帮助更轻松地处理异步 ContentResolver查询。

Summary

Nested classes

class AsyncQueryHandler.WorkerArgs

 

class AsyncQueryHandler.WorkerHandler

 

Public constructors

AsyncQueryHandler(ContentResolver cr)

Public methods

final void cancelOperation(int token)

试图取消尚未开始的操作。

void handleMessage(Message msg)

子类必须实现这个才能接收消息。

final void startDelete(int token, Object cookie, Uri uri, String selection, String[] selectionArgs)

该方法开始异步删除。

final void startInsert(int token, Object cookie, Uri uri, ContentValues initialValues)

该方法开始一个异步插入。

void startQuery(int token, Object cookie, Uri uri, String[] projection, String selection, String[] selectionArgs, String orderBy)

此方法开始一个异步查询。

final void startUpdate(int token, Object cookie, Uri uri, ContentValues values, String selection, String[] selectionArgs)

此方法开始异步更新。

Protected methods

Handler createHandler(Looper looper)
void onDeleteComplete(int token, Object cookie, int result)

当异步删除完成时调用。

void onInsertComplete(int token, Object cookie, Uri uri)

当异步插入完成时调用。

void onQueryComplete(int token, Object cookie, Cursor cursor)

当异步查询完成时调用。

void onUpdateComplete(int token, Object cookie, int result)

当异步更新完成时调用。

Inherited methods

From class android.os.Handler
From class java.lang.Object

Public constructors

AsyncQueryHandler

Added in API level 1
AsyncQueryHandler (ContentResolver cr)

Parameters
cr ContentResolver

Public methods

cancelOperation

Added in API level 1
void cancelOperation (int token)

试图取消尚未开始的操作。 请注意,不保证该操作将被取消。 在此通话完成后,他们仍可能会导致[查询/插入/更新/删除]完成。

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

handleMessage

Added in API level 1
void handleMessage (Message msg)

子类必须实现这个才能接收消息。

Parameters
msg Message

startDelete

Added in API level 1
void startDelete (int token, 
                Object cookie, 
                Uri uri, 
                String selection, 
                String[] selectionArgs)

该方法开始异步删除。 删除操作完成onDeleteComplete(int, Object, int) ,调用onDeleteComplete(int, Object, int)

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

startInsert

Added in API level 1
void startInsert (int token, 
                Object cookie, 
                Uri uri, 
                ContentValues initialValues)

该方法开始一个异步插入。 当插入操作完成onInsertComplete(int, Object, Uri) ,调用onInsertComplete(int, Object, Uri)

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

startQuery

Added in API level 1
void startQuery (int token, 
                Object cookie, 
                Uri uri, 
                String[] projection, 
                String selection, 
                String[] selectionArgs, 
                String orderBy)

此方法开始一个异步查询。 查询完成onQueryComplete(int, Object, Cursor) ,调用onQueryComplete(int, Object, Cursor)

Parameters
token int: A token passed into onQueryComplete(int, Object, Cursor) to identify the query.
cookie Object: An object that gets passed into onQueryComplete(int, Object, Cursor)
uri Uri: The URI, using the content:// scheme, for the content to retrieve.
projection String: 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 String: 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 String: 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 String: 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.

startUpdate

Added in API level 1
void startUpdate (int token, 
                Object cookie, 
                Uri uri, 
                ContentValues values, 
                String selection, 
                String[] selectionArgs)

此方法开始异步更新。 更新操作完成onUpdateComplete(int, Object, int) ,调用onUpdateComplete(int, Object, int)

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

Protected methods

createHandler

Added in API level 1
Handler createHandler (Looper looper)

Parameters
looper Looper
Returns
Handler

onDeleteComplete

Added in API level 1
void onDeleteComplete (int token, 
                Object cookie, 
                int result)

当异步删除完成时调用。

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

onInsertComplete

Added in API level 1
void onInsertComplete (int token, 
                Object cookie, 
                Uri uri)

当异步插入完成时调用。

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

onQueryComplete

Added in API level 1
void onQueryComplete (int token, 
                Object cookie, 
                Cursor cursor)

当异步查询完成时调用。

Parameters
token int: the token to identify the query, passed in from startQuery(int, Object, Uri, String[], String, String[], String).
cookie Object: the cookie object passed in from startQuery(int, Object, Uri, String[], String, String[], String).
cursor Cursor: The cursor holding the results from the query.

onUpdateComplete

Added in API level 1
void onUpdateComplete (int token, 
                Object cookie, 
                int result)

当异步更新完成时调用。

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

Hooray!