public class DataAbilityAsyncHandler extends EventHandler
DataAbilityHelper instance.
This class provides two threads, a work thread and a callback thread. The work thread implements data operations; the callback thread processes data operation results.
SystemCapability.Data#DATA_APPDATAMGREventHandler.Priority| 构造器 | 说明 |
|---|---|
DataAbilityAsyncHandler(Context context) |
Creates a
DataAbilityAsyncHandler instance using a Context. |
DataAbilityAsyncHandler(Context context,
Uri uri) |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addDeleteJob(JobParams jobParams,
Uri uri,
DataAbilityPredicates dataAbilityPredicates,
DeleteCallback deleteCallback) |
Deletes data from the database asynchronously and processes the deletion result.
|
void |
addInsertJob(JobParams jobParams,
Uri uri,
ValuesBucket valuesBucket,
InsertCallback insertCallback) |
Inserts data into the database asynchronously and processes the insertion result.
|
void |
addQueryJob(JobParams jobParams,
Uri uri,
String[] columns,
DataAbilityPredicates dataAbilityPredicates,
QueryCallback queryCallback) |
Queries data in the database asynchronously and processes the query result.
|
void |
addUpdateJob(JobParams jobParams,
Uri uri,
ValuesBucket valuesBucket,
DataAbilityPredicates dataAbilityPredicates,
UpdateCallback updateCallback) |
Updates data in the database asynchronously and processes the update result.
|
void |
cancelJob(int token) |
Cancels asynchronous tasks with the same token.
|
protected void |
finalize() |
When we do not use current instance, we should release dataAbilityHelper.
|
current, distributeEvent, dump, getEventName, getEventRunner, hasInnerEvent, hasInnerEvent, hasInnerEvent, hasInnerEvent, hasInnerEvent, isIdle, postSyncTask, postSyncTask, postTask, postTask, postTask, postTask, postTask, postTimingTask, postTimingTask, postTimingTask, processEvent, removeAllEvent, removeEvent, removeEvent, removeEvent, removeEvent, removeTask, removeTask, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendSyncEvent, sendSyncEvent, sendSyncEvent, sendSyncEvent, sendTimingEvent, sendTimingEvent, sendTimingEvent, sendTimingEvent, toStringpublic DataAbilityAsyncHandler(Context context)
DataAbilityAsyncHandler instance using a Context.
This constructor is used if the asynchronous Uri points to a different device or provider.
context - Indicates the application context.public DataAbilityAsyncHandler(Context context, Uri uri)
DataAbilityAsyncHandler instance using a Context and Uri.
This constructor is more efficient and recommended if the asynchronous Uri points to
the same device or provider.
context - Indicates the application context.uri - Indicates the resource URI.public final void addQueryJob(JobParams jobParams, Uri uri, String[] columns, DataAbilityPredicates dataAbilityPredicates, QueryCallback queryCallback)
Use this method when querying a large amount of data in the database in the cross-process or cross-device scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.uri - Indicates the resource URI. It cannot be null.columns - Indicates the columns where the data to be queried resides. If it is null,
data in all the columns will be queried.dataAbilityPredicates - Indicates the DataAbilityPredicates. It is mandatory
and cannot be null.queryCallback - Indicates the QueryCallback used to process the query result. It is
mandatory and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addInsertJob(JobParams jobParams, Uri uri, ValuesBucket valuesBucket, InsertCallback insertCallback)
Use this method when inserting a large amount of data into the database in the cross-process or cross-device scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.uri - Indicates the resource URI. It cannot be null.valuesBucket - Indicates a bucket that stores and manages values. It is mandatory and cannot
be null. For details, see ValuesBucket.insertCallback - Indicates the InsertCallback used to process the insertion result. It is mandatory
and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addUpdateJob(JobParams jobParams, Uri uri, ValuesBucket valuesBucket, DataAbilityPredicates dataAbilityPredicates, UpdateCallback updateCallback)
Use this method when updating a large amount of data in the database in the cross-process or cross-device scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.uri - Indicates the resource URI. It cannot be null.valuesBucket - Indicates a bucket that stores and manages values. It is mandatory and cannot
be null. For details, see ValuesBucket.dataAbilityPredicates - Indicates the DataAbilityPredicates. It is mandatory and cannot
be null.updateCallback - Indicates the UpdateCallback used to process the update result. It is
mandatory and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.public final void addDeleteJob(JobParams jobParams, Uri uri, DataAbilityPredicates dataAbilityPredicates, DeleteCallback deleteCallback)
Use this method when deleting a large amount of data from the database in the cross-process or cross-device scenario.
jobParams - Indicates mandatory parameters of the task. For details, see JobParams.uri - Indicates the resource URI. It cannot be null.dataAbilityPredicates - Indicates the DataAbilityPredicates. It is mandatory and cannot
be null.deleteCallback - Indicates the DeleteCallback used to process the deletion result. It is
mandatory and cannot be null.IllegalArgumentException - Throws this exception if a parameter is illegal.protected void finalize()
finalize 在类中 ObjectWeakReference,
PhantomReferencepublic final void cancelJob(int token)
If different tasks share a token, use this method to cancel these tasks.
token - Indicates the token shared by the tasks. It must be consistent with that in the
input parameter jobParams of the addDeleteJob, addInsertJob,
addQueryJob, and addUpdateJob methods.