From ebcafad1f3b7727ae4cb3edaf2ad56f2a80ba434 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Wed, 6 Jul 2022 11:47:32 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-document.md | 116 ++++---- .../reference/apis/js-apis-securityLabel.md | 65 +++-- .../apis/js-apis-storage-statistics.md | 256 ++++++++++-------- 3 files changed, 233 insertions(+), 204 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md index 2291c06482..458685119e 100644 --- a/en/application-dev/reference/apis/js-apis-document.md +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -1,6 +1,6 @@ # File Interaction -> **NOTE**
+> **NOTE**
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. @@ -12,28 +12,29 @@ import document from '@ohos.document'; ## document.choose -choose(type:string[]): Promise<string> +choose(types? : string[]): Promise<string> Chooses a file of the specified type using the file manager. This API uses a promise to return the result. -**System capability**: SystemCapability.FileManagement.File.FileIO +**System capability**: SystemCapability.FileManagement.UserFileService -- Parameters +**Parameters** -| Name| Type | Mandatory | Description | -| ------ | ------ | ---- | ---------------------------- | -| type | string[] | No | Type of the file to choose. | + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | types | string[] | No | Type of the file to choose.| -- Return value +**Return value** -| Type | Description | -| --------------------- | -------------- | -| Promise<string> | Promise used to return the result. An error code is returned. | + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | Promise used to return the result. An error code is returned.| -- Example +**Example** ```js - await document.choose(type); + let types = []; + document.choose(types); ``` ## document.choose @@ -41,91 +42,98 @@ choose(callback:AsyncCallback<string>): void Chooses a file using the file manager. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.FileManagement.File.FileIO +**System capability**: SystemCapability.FileManagement.UserFileService -- Parameters +**Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| -- Example +**Example** ```js - await document.choose(function(err, uri) { + let uri = ""; + document.choose(function(err, uri) { // Do something with the URI. }); ``` ## document.choose -choose(type:string[], callback:AsyncCallback<string>): void +choose(types:string[], callback:AsyncCallback<string>): void -Chooses a file of the specified type using the file manager. This API uses an asynchronous callback to return the result. +Chooses a file using the file manager. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.FileManagement.File.FileIO +**System capability**: SystemCapability.FileManagement.UserFileService -- Parameters +**Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| type | string[] | No | Type of the file to choose. | -| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | types | string[] | No | Type of the file to choose.| + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| -- Example +**Example** ```js - await document.choose(type, function(err, uri) { + let types = []; + let uri = ""; + document.choose(types, function(err, uri) { // Do something with the URI. }); ``` ## document.show -show(url:string, type:string):Promise<number> +show(uri:string, type:string):Promise<void> Opens a file. This API uses a promise to return the result. -**System capability**: SystemCapability.FileManagement.File.FileIO +**System capability**: SystemCapability.FileManagement.UserFileService -- Parameters +**Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------- | -| uri | string | Yes | URI of the file to open. | -| type | string | Yes | Type of the file to open. | + | Name| Type | Mandatory| Description | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open.| + | type | string | Yes | Type of the file to open.| -- Return value +**Return value** -| Type | Description | -| --------------------- | ------------ | -| Promise<void> | Promise used to return the result. An error code is returned. | + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Promise used to return the result. An error code is returned.| -- Example +**Example** ```js - await document.show(uri, type); + let type = ""; + let uri = ""; + document.show(uri, type); ``` ## document.show -show(url:string, type:string, callback:AsyncCallback<void>): void +show(uri:string, type:string, callback:AsyncCallback<void>): void Opens a file. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.FileManagement.File.FileIO +**System capability**: SystemCapability.FileManagement.UserFileService -- Parameters +**Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| uri | string | Yes | URI of the file to open. | -| type | string | Yes | Type of the file to open. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open.| + | type | string | Yes | Type of the file to open.| + | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | -- Example +**Example** ```js - await document.show(uri, type, function(err) { + let type = ""; + let uri = ""; + document.show(uri, type, function(err) { //do something }); - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/reference/apis/js-apis-securityLabel.md b/en/application-dev/reference/apis/js-apis-securityLabel.md index e552e2032a..af95f639fb 100644 --- a/en/application-dev/reference/apis/js-apis-securityLabel.md +++ b/en/application-dev/reference/apis/js-apis-securityLabel.md @@ -3,7 +3,7 @@ > **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -The APIs of this module can be used to obtain and set file security levels. +Manages file data security levels, including obtaining and setting file data security levels. ## Modules to Import @@ -15,34 +15,26 @@ import securityLabel from '@ohos.securityLabel'; Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md). -Application sandbox path of a file or directory = Application directory + File name or directory name - -For example, if the application directory obtained by using **getOrCreateLocalDir** is **dir** and the file name is **xxx.txt**, the application sandbox path of the file is as follows: - ```js -let path = dir + "/xxx.txt"; -``` - -The file descriptor is as follows: - -```js -let fd = fileio.openSync(path, 0o102, 0o666); +import featureAbility from '@ohos.ability.featureAbility'; +let context = featureAbility.getContext(); +let path = context.getFilesDir(); ``` ## securityLabel.setSecurityLabel -setSecurityLabel(path:string, dataLevel:string):Promise<void> +setSecurityLabel(path:string, type:dataLevel):Promise<void> Sets the security label for a file in asynchronous mode. This API uses a promise to return the result. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | -------------------------------------------- | -| path | string | Yes | File path. | -| dataLevel | string | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | -------------------------------------------- | +| path | string | Yes | File path. | +| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| **Return value** @@ -53,7 +45,8 @@ Sets the security label for a file in asynchronous mode. This API uses a promise **Example** ```js - securityLabel.setSecurityLabel(path, dataLevel).then(function(){ + let type = "s4"; + securityLabel.setSecurityLabel(path, type).then(function(){ console.info("setSecurityLabel successfully"); }).catch(function(error){ console.info("setSecurityLabel failed with error:" + error); @@ -62,46 +55,48 @@ Sets the security label for a file in asynchronous mode. This API uses a promise ## securityLabel.setSecurityLabel -setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback<void>):void +setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback<void>):void Sets the security label for a file in asynchronous mode. This API uses a callback to return the result. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** | Name | Type | Mandatory| Description | | --------- | ------------------------- | ---- | -------------------------------------------- | | path | string | Yes | File path. | -| dataLevel | string | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| +| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js - securityLabel.setSecurityLabel(path, dataLevel, function(error){ + let type = "s4"; + securityLabel.setSecurityLabel(path, type, function(error){ console.info("setSecurityLabel:" + JSON.stringify(error)); }); ``` ## securityLabel.setSecurityLabelSync -setSecurityLabelSync(path:string, dataLevel:string):void +setSecurityLabelSync(path:string, type:dataLevel):void Sets the security label for a file in synchronous mode. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** | Name | Type | Mandatory| Description | | --------- | ------ | ---- | -------------------------------------------- | | path | string | Yes | File path. | -| dataLevel | string | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| +| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| **Example** ```js -securityLabel.setSecurityLabelSync(path, dataLevel); +let type = "s4"; +securityLabel.setSecurityLabelSync(path, type); ``` ## securityLabel.getSecurityLabel @@ -110,7 +105,7 @@ getSecurityLabel(path:string):Promise<string> Obtains the security label of a file in asynchronous mode. This API uses a promise to return the result. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** @@ -127,8 +122,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi **Example** ```js - securityLabel.getSecurityLabel(path).then(function(dataLevel){ - console.log("getSecurityLabel successfully:" + dataLevel); + let type = "s4"; + securityLabel.getSecurityLabel(path).then(function(type){ + console.log("getSecurityLabel successfully:" + type); }).catch(function(error){ console.log("getSecurityLabel failed with error:" + error); }); @@ -140,7 +136,7 @@ getSecurityLabel(path:string, callback:AsyncCallback<string>): void Obtains the security label of a file in asynchronous mode. This API uses a callback to return the result. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** @@ -152,8 +148,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb **Example** ```js - securityLabel.getSecurityLabel(function(error, dataLevel){ - console.log("getSecurityLabel successfully:" + dataLevel); + let type = "s4"; + securityLabel.getSecurityLabel(path,function(error, type){ + console.log("getSecurityLabel successfully:" + type); }); ``` ## securityLabel.getSecurityLabelSync @@ -162,7 +159,7 @@ getSecurityLabelSync(path:string):string Obtains the security label of a file in synchronous mode. -**System capability**: SystemCapability.FileManagement.File.DistributedFile +**System capability**: SystemCapability.FileManagement.File.FileIO **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md index a0b973cb89..e99f0a560b 100644 --- a/en/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -10,10 +10,10 @@ Obtains storage space information, including the space of built-in and plug-in m ## Modules to Import ```js -import storagestatistics from "@ohos.storageStatistics"; +import storageStatistics from "@ohos.storageStatistics"; ``` -## storagestatistics.getTotalSizeOfVolume +## storageStatistics.getTotalSizeOfVolume getTotalSizeOfVolume(volumeUuid: string): Promise<number> @@ -23,32 +23,34 @@ Asynchronously obtains the total size of the specified volume. This API uses a p **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | | volumeUuid | string | Yes | UUID of the volume.| -- Return value +**Return value** | Type | Description | | --------------------- | ---------------- | | Promise<number> | Promise used to return the total size of the volume.| -- Example +**Example** ```js let uuid = ""; - storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){ + storageStatistics.getTotalSizeOfVolume(uuid).then(function(number){ console.info("getTotalSizeOfVolume successfully:"+ number); }).catch(function(err){ console.info("getTotalSizeOfVolume failed with error:"+ err); }); ``` -## storagestatistics.getTotalSizeOfVolume +## storageStatistics.getTotalSizeOfVolume getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void @@ -58,28 +60,28 @@ Asynchronously obtains the total size of the specified volume. This API uses a c **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | -------------------------- | | volumeUuid | string | Yes | UUID of the volume. | | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the total size of the volume.| -- Example +**Example** ```js let uuid = ""; - storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ + storageStatistics.getTotalSizeOfVolume(uuid, function(error, number){ // Do something. console.info("getTotalSizeOfVolume successfully:"+ number); }); ``` - - -## storagestatistics.getFreeSizeOfVolume +## storageStatistics.getFreeSizeOfVolume getFreeSizeOfVolume(volumeUuid: string): Promise<number> @@ -89,25 +91,27 @@ Asynchronously obtains the available space of the specified volume. This API use **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | | volumeUuid | string | Yes | UUID of the volume.| -- Return value +**Return value** | Type | Description | | --------------------- | ------------------ | | Promise<number> | Promise used to return the available space of the volume.| -- Example +**Example** ```js let uuid = ""; - storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){ + storageStatistics.getFreeSizeOfVolume(uuid).then(function(number){ console.info("getFreeSizeOfVolume successfully:"+ number); }).catch(function(err){ console.info("getFreeSizeOfVolume failed with error:"+ err); @@ -115,7 +119,7 @@ Asynchronously obtains the available space of the specified volume. This API use ``` -## storagestatistics.getFreeSizeOfVolume +## storageStatistics.getFreeSizeOfVolume getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void @@ -125,26 +129,28 @@ Asynchronously obtains the available space of the specified volume. This API use **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | ---------------------------- | | volumeUuid | string | Yes | UUID of the volume. | | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the available space of the volume.| -- Example +**Example** ```js let uuid = ""; - storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ + storageStatistics.getFreeSizeOfVolume(uuid, function(error, number){ // Do something. console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` -## storagestatistics.getBundleStats9+ +## storageStatistics.getBundleStats9+ getBundleStats(packageName: string): Promise<BundleStats> @@ -154,32 +160,34 @@ Asynchronously obtains space information of an application. This API uses a prom **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | ----------- | ------ | ---- | -------- | | packageName | string | Yes | Bundle name of the application.| - -- Return value + +**Return value** | Type | Description | | ------------------------------------------ | -------------------------- | | Promise<[Bundlestats](#bundlestats)> | Promise used to return the space information obtained.| -- Example +**Example** ```js let packageName = ""; - storagestatistics.getBundleStats(packageName).then(function(BundleStats){ + storageStatistics.getBundleStats(packageName).then(function(BundleStats){ console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }).catch(function(err){ console.info("getBundleStats failed with error:"+ err); }); ``` -## storagestatistics.getBundleStats9+ +## storageStatistics.getBundleStats9+ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void @@ -189,78 +197,80 @@ Asynchronously obtains space information of an application. This API uses a call **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | packageName | string | Yes | Bundle name of the application.| | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the space information obtained.| - -- Example + +**Example** ```js let packageName = ""; - storagestatistics.getBundleStats(packageName, function(error, BundleStats){ + storageStatistics.getBundleStats(packageName, function(error, BundleStats){ // Do something. console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }); ``` +## storageStatistics.getCurrentBundleStats9+ - -## storagestatistics.getCurrentBundleStats9+ - -getCurrentBundleStats(): Promise +getCurrentBundleStats(): Promise<BundleStats> Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -- Return value +**Return value** | Type | Description | | ------------------------------------------ | -------------------------- | | Promise<[Bundlestats](#bundlestats)> | Promise used to return the space information obtained. | -- Example +**Example** ```js - let bundleStats = await storageStatistics.getCurrentBundleStats(); - console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); + let bundleStats = storageStatistics.getCurrentBundleStats(); + console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); ``` -## storagestatistics.getCurrentBundleStats9+ +## storageStatistics.getCurrentBundleStats9+ -getCurrentBundleStats(callback: AsyncCallback): void +getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result. **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -- Parameters +**Parameters** | Name | Type | Mandatory | Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | Yes | Callback invoked to return the space information obtained. | -- Example +**Example** ```js - storagestatistics.getCurrentBundleStats(function(error, bundleStats){ + storageStatistics.getCurrentBundleStats(function(error, bundleStats){ // Do something. console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); }); ``` - - - + ## BundleStats9+ **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -- Attributes + +This is a system API and cannot be called by third-party applications. + + +### Attributes | Name | Type | Description | | --------- | ------ | -------------- | @@ -269,11 +279,9 @@ Asynchronously obtains space information of the current third-party application. | dataSize | number | Total data size of the application.| +## storageStatistics.getTotalSize9+ - -## storagestatistics.getTotalSize9+ - -getTotalSize(): Promise +getTotalSize(): Promise<number> Obtains the total space of the built-in memory card. This API uses a promise to return the result. @@ -281,24 +289,26 @@ Obtains the total space of the built-in memory card. This API uses a promise to **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Return value +This is a system API and cannot be called by third-party applications. + + +**Return value** | Type | Description | | --------------------- | ------------------ | | Promise<number> | Promise used to return the total space of the built-in memory card. | -- Example +**Example** ```js - let number = await storageStatistics.getTotalSize(); - console.info("getTotalSize successfully:"+ JSON.stringify(number)); + let number = storageStatistics.getTotalSize(); + console.info("getTotalSize successfully:"+ JSON.stringify(number)); ``` - -## storagestatistics.getTotalSize9+ -getTotalSize(callback: AsyncCallback): void +## storageStatistics.getTotalSize9+ + +getTotalSize(callback: AsyncCallback<number>): void Obtains the total space of the built-in memory card. This API uses a callback to return the result. @@ -306,27 +316,29 @@ Obtains the total space of the built-in memory card. This API uses a callback to **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory | Description | | -------- | ------------------------------------ | ---- | ------------------------ | | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the total space of the built-in memory card.| -- Example +**Example** ```js - storagestatistics.getTotalSize(function(error, number){ + storageStatistics.getTotalSize(function(error, number){ // Do something. console.info("getTotalSize successfully:"+ JSON.stringify(number)); }); ``` -## storagestatistics.getFreeSize9+ +## storageStatistics.getFreeSize9+ -getFreeSize(): Promise +getFreeSize(): Promise<number> Obtains the available space of the built-in memory card. This API uses a promise to return the result. @@ -334,25 +346,27 @@ Obtains the available space of the built-in memory card. This API uses a promise **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Return value +This is a system API and cannot be called by third-party applications. + + +**Return value** | Type | Description | | --------------------- | ------------------ | | Promise<number> | Promise used to return the available space of the built-in memory card.| -- Example +**Example** ```js - let number = await storageStatistics.getFreeSize(); - console.info("getFreeSize successfully:"+ JSON.stringify(number)); + let number = storageStatistics.getFreeSize(); + console.info("getFreeSize successfully:"+ JSON.stringify(number)); ``` -## storagestatistics.getFreeSize9+ +## storageStatistics.getFreeSize9+ -getFreeSize(callback: AsyncCallback): void +getFreeSize(callback: AsyncCallback<number>): void Obtains the available space of the built-in memory card. This API uses a callback to return the result. @@ -360,26 +374,26 @@ Obtains the available space of the built-in memory card. This API uses a callbac **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------- | | callback | callback:AsyncCallback<number> | Yes | Callback invoked to return the available space of the built-in memory card.| -- Example +**Example** ```js - storagestatistics.getFreeSize(function(error, number){ + storageStatistics.getFreeSize(function(error, number){ // Do something. console.info("getFreeSize successfully:"+ JSON.stringify(number)); }); ``` - - -## storagestatistics.getSystemSize9+ +## storageStatistics.getSystemSize9+ getSystemSize(): Promise<number> @@ -389,25 +403,27 @@ Asynchronously obtains the system space. This API uses a promise to return the r **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Return value +This is a system API and cannot be called by third-party applications. + + +**Return value** | Type | Description | | --------------------- | ---------------- | | Promise<number> | Promise used to return the system space obtained.| -- Example +**Example** ```js - storagestatistics.getSystemSize().then(function(number){ + storageStatistics.getSystemSize().then(function(number){ console.info("getSystemSize successfully:"+ number); }).catch(function(err){ console.info("getSystemSize failed with error:"+ err); }); ``` -## storagestatistics.getSystemSize9+ +## storageStatistics.getSystemSize9+ getSystemSize(callback:AsyncCallback<number>):void @@ -417,28 +433,28 @@ Asynchronously obtains the system space. This API uses a callback to return the **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | -------------------------- | | callback | callback:AsyncCallback<number> | Yes | Callback used to return the system space obtained.| -- Example +**Example** ```js - storagestatistics.getSystemSize(function(error, number){ + storageStatistics.getSystemSize(function(error, number){ // Do something. console.info("getSystemSize successfully:"+ number); }); ``` - - - -## storagestatistics.getUserStorageStats9+ -getUserStorageStats(userId?: string): Promise<StorageStats> +## storageStatistics.getUserStorageStats9+ + +getUserStorageStats(userId? : number): Promise<StorageStats> Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result. @@ -446,34 +462,36 @@ Asynchronously obtains the space occupied by each type of user data. This API us **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | - | userId | string | No | User ID.
-  Set this parameter to the ID of the user to be queried.
-  If no value is specified, information about the current user is queried.| + | userId | string | No | User ID.
Value:
-  Set this parameter to the ID of the user to be queried.
-  If no value is specified, information about the current user is queried.| -- Return value +**Return value** | Type | Description | | --------------------- | ---------------- | | Promise<[StorageStats](#StorageStats)> | Promise used to return the information obtained.| -- Example +**Example** ```js let userId = ""; - storagestatistics.getUserStorageStats(userId).then(function(StorageStats){ + storageStatistics.getUserStorageStats(userId).then(function(StorageStats){ console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); }).catch(function(err){ console.info("getUserStorageStats failed with error:"+ err); }); ``` -## storagestatistics.getUserStorageStats9+ +## storageStatistics.getUserStorageStats9+ -getUserStorageStats(userId?: string, callback:AsyncCallback<StorageStats>):void +getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>):void Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result. @@ -481,31 +499,37 @@ Asynchronously obtains the space occupied by each type of user data. This API us **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -**System API**: This is a system API and cannot be called by third-party applications. -- Parameters +This is a system API and cannot be called by third-party applications. + + +**Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | -------------------------- | - | userId | string | No | User ID.
-  Set this parameter to the ID of the user to be queried.
-  If no value is specified, information about the current user is queried. | + | userId | string | No | User ID.
Value:
-  Set this parameter to the ID of the user to be queried.
-  If no value is specified, information about the current user is queried. | | callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | Yes | Callback invoked to return the information obtained.| -- Example +**Example** ```js - storagestatistics.getUserStorageStats(userId, function(error, StorageStats){ + let userId = ""; + storageStatistics.getUserStorageStats(userId, function(error, StorageStats){ // Do something. console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); }); ``` - ## StorageStats9+ **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics -- Attributes + +This is a system API and cannot be called by third-party applications. + + +### Attributes | Name | Type | Description | | --------- | ------ | -------------- | -- GitLab