IAssistanceChannel, IAbilityContinuation, ILifecycle, Contextpublic class AceDataAbility extends AceAbility
Ability. Any class specific to application running
should derive from AceDataAbility.Ability.LayoutParamsHelper, Ability.WindowAttributeHelperFORM_INVISIBLE, FORM_VISIBLECONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
AceDataAbility() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
batchInsert(Uri uri,
ValuesBucket[] values) |
Inserts multiple data records into the database.
|
PacMap |
call(String method,
String arg,
PacMap extras) |
Defines a method in this Data ability (implementation depending on child classes).
|
int |
delete(Uri uri,
DataAbilityPredicates predicates) |
Deletes one or more data records.
|
Uri |
denormalizeUri(Uri uri) |
Converts the given normalized
uri generated by Ability.normalizeUri(ohos.utils.net.Uri) into a denormalized one. |
DataAbilityResult[] |
executeBatch(ArrayList<DataAbilityOperation> operations) |
Performs batch operations on the database.
|
String[] |
getFileTypes(Uri uri,
String mimeTypeFilter) |
Obtains the MIME type of files.
|
String |
getType(Uri uri) |
Obtains the MIME type matching the data specified by the URI of the Data ability.
|
int |
insert(Uri uri,
ValuesBucket value) |
Inserts a data record into the database.
|
Uri |
normalizeUri(Uri uri) |
Converts the given
uri that refer to the Data ability into a normalized URI. |
protected void |
onInitialized(AbilityInfo abilityInfo) |
Called to carry to this ability after the ability is initialized.
|
void |
onStart(Intent intent) |
Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of
an ability).
|
void |
onStop() |
Called back before an ability is destroyed.
|
FileDescriptor |
openFile(Uri uri,
String mode) |
Opens a file.
|
ResultSet |
query(Uri uri,
String[] columns,
DataAbilityPredicates predicates) |
Queries one or more data records in the database.
|
void |
setInstanceName(String name) |
Sets an instance name.
|
int |
update(Uri uri,
ValuesBucket value,
DataAbilityPredicates predicates) |
Updates one or more data records in the database.
|
addActionRoute, cancelBackgroundRunning, connectAbility, continueAbility, continueAbility, continueAbilityReversibly, continueAbilityReversibly, createPipeFile, disconnectAbility, dispatchAccessibilityEventInfo, executeOperation, findComponentById, getAbilityName, getAbilityPackage, getAdmissionTransitionConcurEnabled, getAdmissionTransitionObject, getAVController, getBackTransitionConcurEnabled, getBackTransitionObject, getContinuationRegisterManager, getContinuationState, getCurrentFocus, getIntent, getLayoutParams, getLifecycle, getOriginalDeviceId, getQuitTransitionObject, getReadmissionTransitionObject, getSharedItemAdmissionTransitionObject, getSharedItemBackTransitionObject, getSharedItemQuitTransitionObject, getSharedItemReadmissionTransitionObject, getState, getVolumeTypeAdjustedByKey, getWindow, hasWindowFocus, isTemporary, isTerminating, keepBackgroundRunning, onAcquireFormState, onCastTempForm, onCommand, onCommand, onConnect, onCreateForm, onCreateForm, onDeleteForm, onDeleteForm, onDisconnect, onEventDispatch, onEventNotify, onHotkeyTriggered, onKeyPressAndHold, onLeaveForeground, onMissionDeleted, onNewDescription, onOrientationChanged, onPostActive, onPostStart, onReconnect, onSetCaller, onStoreDataWhenConfigChange, onTopActiveAbilityChanged, onTriggerFormEvent, onTriggerFormEvent, onUnloadForm, onUpdateForm, onUpdateForm, onWindowFocusChanged, openRawFile, parsePredictionArgsReference, parseValuesBucketReference, postTask, reload, reverseContinueAbility, setAbilitySliceAnimator, setAdmissionTransitionConcurEnabled, setAdmissionTransitionObject, setAVController, setBackTransitionConcurEnabled, setBackTransitionObject, setFormNextRefreshTime, setIntent, setIsAmbientMode, setLayoutParams, setMainRoute, setQuitTransitionObject, setReadmissionTransitionObject, setResult, setSharedItemAdmissionTransitionObject, setSharedItemBackTransitionObject, setSharedItemQuitTransitionObject, setSharedItemReadmissionTransitionObject, setSwipeToDismiss, setUIContent, setUIContent, setVolumeTypeAdjustedByKey, setWindowBackgroundColor, shutdown, startAbility, startAbility, startAbility, startAbility, startAbilityForResult, startAbilityForResult, startAssistAbility, stopAbility, stopAssistAbility, supportHighPerformanceUI, terminateAbility, updateForm, updateForm, updateForm, updateFormattachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, displayUnlockMissionMessage, getAbilityInfo, getAbilityManager, getAbilityPackageContext, getApplicationContext, getApplicationInfo, getAppType, getBundleCodePath, getBundleManager, getBundleName, getBundleResourcePath, getCacheDir, getCaller, getCallingAbility, getCallingBundle, getClassloader, getCodeCacheDir, getColor, getColorMode, getContext, getDatabaseDir, getDataDir, getDir, getDisplayOrientation, getDistributedDir, getElementName, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getGlobalTaskDispatcher, getHapModuleInfo, getIntArray, getLastStoredDataWhenConfigChanged, getLocalClassName, getMainTaskDispatcher, getNoBackupFilesDir, getPattern, getPreferencesDir, getProcessInfo, getProcessName, getResourceManager, getResourceManager, getString, getString, getStringArray, getTheme, getThemeId, getUITaskDispatcher, init, isCredentialEncryptedStorage, isDeviceEncryptedStorage, isUpdatingConfigurations, lockMission, printDrawnCompleted, requestPermissionsFromUser, restart, setColorMode, setDisplayOrientation, setPattern, setShowOnLockScreen, setTheme, setTransitionAnimation, setWakeUpScreen, startAbilities, startAbility, startAbility, startAbility, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissiononAbilityResult, onActive, onBackground, onBackPressed, onCompleteContinuation, onConfigurationUpdated, onConnected, onConnectFailed, onDisconnected, onForeground, onInactive, onKeyDown, onKeyUp, onMemoryLevel, onNewIntent, onNewWant, onRemoteTerminated, onRequestPermissionsFromUserResult, onRestoreAbilityState, onRestoreData, onSaveAbilityState, onSaveData, onStartContinuation, onTouchEvent, pushPage, setPageParamsonFailedContinuationpublic void onStart(Intent intent)
AbilityMost initialization operations should be performed by calling this method. For example, you can use the
current method to call Ability.setMainRoute(java.lang.String) and
Ability.addActionRoute(java.lang.String,java.lang.String) to set the main router and action router for a Page ability.
onStart 在类中 AceAbilityintent - Indicates information carried when this ability is started. Note: For a Service ability,
null is passed.protected void onInitialized(AbilityInfo abilityInfo)
onInitialized 在类中 AbilityabilityInfo - Indicates the object containing information about this ability.public void onStop()
AbilityThis method indicates the end of the ability lifecycle. It can be executed after the ability calls the
Ability.terminateAbility() method or the last ability slice of the ability calls the
AbilitySlice#terminate() method. Generally, this method is used to clear resources.
onStop 在类中 AceAbilitypublic Uri normalizeUri(Uri uri)
Abilityuri that refer to the Data ability into a normalized URI. A normalized URI can be
used across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability
even if the context has changed.
If you implement URI normalization for a Data ability, you must also implement Ability.denormalizeUri(ohos.utils.net.Uri)
to enable URI denormalization. After this feature is enabled, URIs passed to any method that is called on the
Data ability must require normalization verification and denormalization.
The default implementation of this method returns null, indicating that this Data ability does
not support URI normalization.
normalizeUri 在类中 Abilityuri - Indicates the Uri object to normalize.Uri object if the Data ability supports URI normalization;
returns null otherwise.Ability.denormalizeUri(ohos.utils.net.Uri)public Uri denormalizeUri(Uri uri)
Abilityuri generated by Ability.normalizeUri(ohos.utils.net.Uri) into a denormalized one.
The default implementation of this method returns the original URI passed to it.denormalizeUri 在类中 Abilityuri - uri Indicates the Uri object to denormalize.Uri object if the denormalization is successful; returns the original
Uri passed to this method if there is nothing to do; returns null if the data identified by
the original Uri cannot be found in the current environment.Ability.normalizeUri(ohos.utils.net.Uri)public String getType(Uri uri)
AbilityData abilities supports general data types, including text, HTML, and JPEG.
public String[] getFileTypes(Uri uri, String mimeTypeFilter)
AbilitygetFileTypes 在类中 Abilityuri - Indicates the path of the files to obtain.mimeTypeFilter - Indicates the MIME type of the files to obtain. This parameter cannot be set to
null.
1. "*/*": Obtains all types supported by a Data ability.
2. "image/*": Obtains files whose main type is image of any subtype.
3. "*/jpg": Obtains files whose subtype is JPG of any main type.
public FileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException
AbilityopenFile 在类中 Abilityuri - Indicates the path of the file to open.mode - Indicates the open mode, which can be "r" for read-only access, "w" for write-only access (erasing
whatever data is currently in the file), "wt" for write access that truncates any existing file,
"wa" for write-only access to append to any existing data, "rw" for read and write access on any
existing data, or "rwt" for read and write access that truncates any existing file.FileDescriptor object of the file descriptor.FileNotFoundException - Throws this exception if the file does not exist.public PacMap call(String method, String arg, PacMap extras)
Abilitypublic int delete(Uri uri, DataAbilityPredicates predicates)
Abilitypublic int update(Uri uri, ValuesBucket value, DataAbilityPredicates predicates)
Abilityupdate 在类中 Abilityuri - Indicates the database table storing the data to update.value - Indicates the data to update. This parameter can be null.predicates - Indicates filter criteria. If this parameter is null, all data records will be updated by
default.public int insert(Uri uri, ValuesBucket value)
Abilitypublic int batchInsert(Uri uri, ValuesBucket[] values)
AbilitybatchInsert 在类中 Abilityuri - Indicates the position where the data is to insert.values - Indicates the data to insert.public ResultSet query(Uri uri, String[] columns, DataAbilityPredicates predicates)
Abilityquery 在类中 Abilityuri - Indicates the database table storing the data to query.columns - Indicates the columns to be queried, in array, for example, {"name","age"}. You should define
the processing logic when this parameter is null.predicates - Indicates filter criteria. If this parameter is null, all data records will be queried by
default.public DataAbilityResult[] executeBatch(ArrayList<DataAbilityOperation> operations) throws OperationExecuteException
AbilityThe batch operations to be executed on the database are encapsulated as DataAbilityOperation objects.
Each object corresponds to an operation, for example, inserting or deleting. The call result of each operation is
saved to and returned by the data array of the DataAbilityResult type.
executeBatch 在类中 Abilityoperations - Indicates the data operation list, which can contain multiple operations on the database.OperationExecuteException - Throws this exception if the batch operation fails.public void setInstanceName(String name)
setInstanceName 在类中 AceAbilityname - Indicates the instance name. The value cannot be an empty string.
Otherwise, your application cannot run properly.