提交 ebcafad1 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 7d18c4c3
# File Interaction # File Interaction
> **NOTE**<br> > **NOTE**<br/>
> - 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 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. > - 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'; ...@@ -12,28 +12,29 @@ import document from '@ohos.document';
## document.choose ## document.choose
choose(type:string[]): Promise&lt;string&gt; choose(types? : string[]): Promise&lt;string&gt;
Chooses a file of the specified type using the file manager. This API uses a promise to return the result. 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 | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- | | ------ | ------ | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. | | types | string[] | No | Type of the file to choose.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;string&gt; | Promise used to return the result. An error code is returned. | | Promise&lt;string&gt; | Promise used to return the result. An error code is returned.|
- Example **Example**
```js ```js
await document.choose(type); let types = [];
document.choose(types);
``` ```
## document.choose ## document.choose
...@@ -41,91 +42,98 @@ choose(callback:AsyncCallback&lt;string&gt;): void ...@@ -41,91 +42,98 @@ choose(callback:AsyncCallback&lt;string&gt;): void
Chooses a file 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 | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned.|
- Example **Example**
```js ```js
await document.choose(function(err, uri) { let uri = "";
document.choose(function(err, uri) {
// Do something with the URI. // Do something with the URI.
}); });
``` ```
## document.choose ## document.choose
choose(type:string[], callback:AsyncCallback&lt;string&gt;): void choose(types:string[], callback:AsyncCallback&lt;string&gt;): 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 | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. | | types | string[] | No | Type of the file to choose.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned.|
- Example **Example**
```js ```js
await document.choose(type, function(err, uri) { let types = [];
let uri = "";
document.choose(types, function(err, uri) {
// Do something with the URI. // Do something with the URI.
}); });
``` ```
## document.show ## document.show
show(url:string, type:string):Promise&lt;number&gt; show(uri:string, type:string):Promise&lt;void&gt;
Opens a file. This API uses a promise to return the result. 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 | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- | | ---- | ------ | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. | | uri | string | Yes | URI of the file to open.|
| type | string | Yes | Type of the file to open. | | type | string | Yes | Type of the file to open.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result. An error code is returned. | | Promise&lt;void&gt; | Promise used to return the result. An error code is returned.|
- Example **Example**
```js ```js
await document.show(uri, type); let type = "";
let uri = "";
document.show(uri, type);
``` ```
## document.show ## document.show
show(url:string, type:string, callback:AsyncCallback&lt;void&gt;): void show(uri:string, type:string, callback:AsyncCallback&lt;void&gt;): void
Opens a file. This API uses an asynchronous callback to return the result. 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 | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. | | uri | string | Yes | URI of the file to open.|
| type | string | Yes | Type of the file to open. | | type | string | Yes | Type of the file to open.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example **Example**
```js ```js
await document.show(uri, type, function(err) { let type = "";
let uri = "";
document.show(uri, type, function(err) {
//do something //do something
}); });
``` ```
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
> **NOTE**<br/> > **NOTE**<br/>
> 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 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 ## Modules to Import
...@@ -15,34 +15,26 @@ import securityLabel from '@ohos.securityLabel'; ...@@ -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). 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 ```js
let path = dir + "/xxx.txt"; import featureAbility from '@ohos.ability.featureAbility';
``` let context = featureAbility.getContext();
let path = context.getFilesDir();
The file descriptor is as follows:
```js
let fd = fileio.openSync(path, 0o102, 0o666);
``` ```
## securityLabel.setSecurityLabel ## securityLabel.setSecurityLabel
setSecurityLabel(path:string, dataLevel:string):Promise&lt;void&gt; setSecurityLabel(path:string, type:dataLevel):Promise&lt;void&gt;
Sets the security label for a file in asynchronous mode. This API uses a promise to return the result. 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** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------------------------------------------- | | --------- | ------ | ---- | -------------------------------------------- |
| path | string | Yes | File path. | | 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**.|
**Return value** **Return value**
...@@ -53,7 +45,8 @@ Sets the security label for a file in asynchronous mode. This API uses a promise ...@@ -53,7 +45,8 @@ Sets the security label for a file in asynchronous mode. This API uses a promise
**Example** **Example**
```js ```js
securityLabel.setSecurityLabel(path, dataLevel).then(function(){ let type = "s4";
securityLabel.setSecurityLabel(path, type).then(function(){
console.info("setSecurityLabel successfully"); console.info("setSecurityLabel successfully");
}).catch(function(error){ }).catch(function(error){
console.info("setSecurityLabel failed with error:" + 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 ...@@ -62,46 +55,48 @@ Sets the security label for a file in asynchronous mode. This API uses a promise
## securityLabel.setSecurityLabel ## securityLabel.setSecurityLabel
setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback&lt;void&gt;):void setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback&lt;void&gt;):void
Sets the security label for a file in asynchronous mode. This API uses a callback to return the result. 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** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | -------------------------------------------- | | --------- | ------------------------- | ---- | -------------------------------------------- |
| path | string | Yes | File path. | | 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&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
securityLabel.setSecurityLabel(path, dataLevel, function(error){ let type = "s4";
securityLabel.setSecurityLabel(path, type, function(error){
console.info("setSecurityLabel:" + JSON.stringify(error)); console.info("setSecurityLabel:" + JSON.stringify(error));
}); });
``` ```
## securityLabel.setSecurityLabelSync ## securityLabel.setSecurityLabelSync
setSecurityLabelSync(path:string, dataLevel:string):void setSecurityLabelSync(path:string, type:dataLevel):void
Sets the security label for a file in synchronous mode. Sets the security label for a file in synchronous mode.
**System capability**: SystemCapability.FileManagement.File.DistributedFile **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------------------------------------------- | | --------- | ------ | ---- | -------------------------------------------- |
| path | string | Yes | File path. | | 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** **Example**
```js ```js
securityLabel.setSecurityLabelSync(path, dataLevel); let type = "s4";
securityLabel.setSecurityLabelSync(path, type);
``` ```
## securityLabel.getSecurityLabel ## securityLabel.getSecurityLabel
...@@ -110,7 +105,7 @@ getSecurityLabel(path:string):Promise&lt;string&gt; ...@@ -110,7 +105,7 @@ getSecurityLabel(path:string):Promise&lt;string&gt;
Obtains the security label of a file in asynchronous mode. This API uses a promise to return the result. 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** **Parameters**
...@@ -127,8 +122,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi ...@@ -127,8 +122,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
**Example** **Example**
```js ```js
securityLabel.getSecurityLabel(path).then(function(dataLevel){ let type = "s4";
console.log("getSecurityLabel successfully:" + dataLevel); securityLabel.getSecurityLabel(path).then(function(type){
console.log("getSecurityLabel successfully:" + type);
}).catch(function(error){ }).catch(function(error){
console.log("getSecurityLabel failed with error:" + error); console.log("getSecurityLabel failed with error:" + error);
}); });
...@@ -140,7 +136,7 @@ getSecurityLabel(path:string, callback:AsyncCallback&lt;string&gt;): void ...@@ -140,7 +136,7 @@ getSecurityLabel(path:string, callback:AsyncCallback&lt;string&gt;): void
Obtains the security label of a file in asynchronous mode. This API uses a callback to return the result. 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** **Parameters**
...@@ -152,8 +148,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb ...@@ -152,8 +148,9 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
**Example** **Example**
```js ```js
securityLabel.getSecurityLabel(function(error, dataLevel){ let type = "s4";
console.log("getSecurityLabel successfully:" + dataLevel); securityLabel.getSecurityLabel(path,function(error, type){
console.log("getSecurityLabel successfully:" + type);
}); });
``` ```
## securityLabel.getSecurityLabelSync ## securityLabel.getSecurityLabelSync
...@@ -162,7 +159,7 @@ getSecurityLabelSync(path:string):string ...@@ -162,7 +159,7 @@ getSecurityLabelSync(path:string):string
Obtains the security label of a file in synchronous mode. Obtains the security label of a file in synchronous mode.
**System capability**: SystemCapability.FileManagement.File.DistributedFile **System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters** **Parameters**
......
...@@ -10,10 +10,10 @@ Obtains storage space information, including the space of built-in and plug-in m ...@@ -10,10 +10,10 @@ Obtains storage space information, including the space of built-in and plug-in m
## Modules to Import ## Modules to Import
```js ```js
import storagestatistics from "@ohos.storageStatistics"; import storageStatistics from "@ohos.storageStatistics";
``` ```
## storagestatistics.getTotalSizeOfVolume ## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt; getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
...@@ -23,32 +23,34 @@ Asynchronously obtains the total size of the specified volume. This API uses a p ...@@ -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 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| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.| | volumeUuid | string | Yes | UUID of the volume.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total size of the volume.| | Promise&lt;number&gt; | Promise used to return the total size of the volume.|
- Example **Example**
```js ```js
let uuid = ""; let uuid = "";
storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){ storageStatistics.getTotalSizeOfVolume(uuid).then(function(number){
console.info("getTotalSizeOfVolume successfully:"+ number); console.info("getTotalSizeOfVolume successfully:"+ number);
}).catch(function(err){ }).catch(function(err){
console.info("getTotalSizeOfVolume failed with error:"+ err); console.info("getTotalSizeOfVolume failed with error:"+ err);
}); });
``` ```
## storagestatistics.getTotalSizeOfVolume ## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
...@@ -58,28 +60,28 @@ Asynchronously obtains the total size of the specified volume. This API uses a c ...@@ -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 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 | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
- Example **Example**
```js ```js
let uuid = ""; let uuid = "";
storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ storageStatistics.getTotalSizeOfVolume(uuid, function(error, number){
// Do something. // Do something.
console.info("getTotalSizeOfVolume successfully:"+ number); console.info("getTotalSizeOfVolume successfully:"+ number);
}); });
``` ```
## storagestatistics.getFreeSizeOfVolume ## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt; getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
...@@ -89,25 +91,27 @@ Asynchronously obtains the available space of the specified volume. This API use ...@@ -89,25 +91,27 @@ Asynchronously obtains the available space of the specified volume. This API use
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **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| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.| | volumeUuid | string | Yes | UUID of the volume.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the volume.| | Promise&lt;number&gt; | Promise used to return the available space of the volume.|
- Example **Example**
```js ```js
let uuid = ""; let uuid = "";
storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){ storageStatistics.getFreeSizeOfVolume(uuid).then(function(number){
console.info("getFreeSizeOfVolume successfully:"+ number); console.info("getFreeSizeOfVolume successfully:"+ number);
}).catch(function(err){ }).catch(function(err){
console.info("getFreeSizeOfVolume failed with error:"+ err); console.info("getFreeSizeOfVolume failed with error:"+ err);
...@@ -115,7 +119,7 @@ Asynchronously obtains the available space of the specified volume. This API use ...@@ -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&lt;number&gt;):void getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
...@@ -125,26 +129,28 @@ Asynchronously obtains the available space of the specified volume. This API use ...@@ -125,26 +129,28 @@ Asynchronously obtains the available space of the specified volume. This API use
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **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 | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | ---------------------------- | | ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.|
- Example **Example**
```js ```js
let uuid = ""; let uuid = "";
storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ storageStatistics.getFreeSizeOfVolume(uuid, function(error, number){
// Do something. // Do something.
console.info("getFreeSizeOfVolume successfully:"+ number); console.info("getFreeSizeOfVolume successfully:"+ number);
}); });
``` ```
## storagestatistics.getBundleStats<sup>9+</sup> ## storageStatistics.getBundleStats<sup>9+</sup>
getBundleStats(packageName: string): Promise&lt;BundleStats&gt; getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
...@@ -154,32 +160,34 @@ Asynchronously obtains space information of an application. This API uses a prom ...@@ -154,32 +160,34 @@ Asynchronously obtains space information of an application. This API uses a prom
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **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 | | Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- | | ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.| | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
- Example **Example**
```js ```js
let packageName = ""; let packageName = "";
storagestatistics.getBundleStats(packageName).then(function(BundleStats){ storageStatistics.getBundleStats(packageName).then(function(BundleStats){
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
}).catch(function(err){ }).catch(function(err){
console.info("getBundleStats failed with error:"+ err); console.info("getBundleStats failed with error:"+ err);
}); });
``` ```
## storagestatistics.getBundleStats<sup>9+</sup> ## storageStatistics.getBundleStats<sup>9+</sup>
getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void
...@@ -189,78 +197,80 @@ Asynchronously obtains space information of an application. This API uses a call ...@@ -189,78 +197,80 @@ Asynchronously obtains space information of an application. This API uses a call
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **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 | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.| | callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.|
- Example **Example**
```js ```js
let packageName = ""; let packageName = "";
storagestatistics.getBundleStats(packageName, function(error, BundleStats){ storageStatistics.getBundleStats(packageName, function(error, BundleStats){
// Do something. // Do something.
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
}); });
``` ```
## storageStatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise&lt;BundleStats&gt;
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise<BundleStats>
Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result. 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 **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Return value **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. | | Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
- Example **Example**
```js ```js
let bundleStats = await storageStatistics.getCurrentBundleStats(); let bundleStats = storageStatistics.getCurrentBundleStats();
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
``` ```
## storagestatistics.getCurrentBundleStats<sup>9+</sup> ## storageStatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void getCurrentBundleStats(callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result. 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 **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Parameters **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. | | callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. |
- Example **Example**
```js ```js
storagestatistics.getCurrentBundleStats(function(error, bundleStats){ storageStatistics.getCurrentBundleStats(function(error, bundleStats){
// Do something. // Do something.
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats)); console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
}); });
``` ```
## BundleStats<sup>9+</sup> ## BundleStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Attributes
This is a system API and cannot be called by third-party applications.
### Attributes
| Name | Type | Description | | Name | Type | Description |
| --------- | ------ | -------------- | | --------- | ------ | -------------- |
...@@ -269,11 +279,9 @@ Asynchronously obtains space information of the current third-party application. ...@@ -269,11 +279,9 @@ Asynchronously obtains space information of the current third-party application.
| dataSize | number | Total data size of the application.| | dataSize | number | Total data size of the application.|
## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise&lt;number&gt;
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise<number>
Obtains the total space of the built-in memory card. This API uses a promise to return the result. 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 ...@@ -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 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 | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. | | Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
- Example **Example**
```js ```js
let number = await storageStatistics.getTotalSize(); let number = storageStatistics.getTotalSize();
console.info("getTotalSize successfully:"+ JSON.stringify(number)); console.info("getTotalSize successfully:"+ JSON.stringify(number));
``` ```
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback<number>): void ## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback&lt;number&gt;): void
Obtains the total space of the built-in memory card. This API uses a callback to return the result. 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 ...@@ -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 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 | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ | | -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
- Example **Example**
```js ```js
storagestatistics.getTotalSize(function(error, number){ storageStatistics.getTotalSize(function(error, number){
// Do something. // Do something.
console.info("getTotalSize successfully:"+ JSON.stringify(number)); console.info("getTotalSize successfully:"+ JSON.stringify(number));
}); });
``` ```
## storagestatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise<number> getFreeSize(): Promise&lt;number&gt;
Obtains the available space of the built-in memory card. This API uses a promise to return the result. 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 ...@@ -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 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 | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.| | Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
- Example **Example**
```js ```js
let number = await storageStatistics.getFreeSize(); let number = storageStatistics.getFreeSize();
console.info("getFreeSize successfully:"+ JSON.stringify(number)); console.info("getFreeSize successfully:"+ JSON.stringify(number));
``` ```
## storagestatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback<number>): void getFreeSize(callback: AsyncCallback&lt;number&gt;): void
Obtains the available space of the built-in memory card. This API uses a callback to return the result. 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 ...@@ -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 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 | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- | | -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
- Example **Example**
```js ```js
storagestatistics.getFreeSize(function(error, number){ storageStatistics.getFreeSize(function(error, number){
// Do something. // Do something.
console.info("getFreeSize successfully:"+ JSON.stringify(number)); console.info("getFreeSize successfully:"+ JSON.stringify(number));
}); });
``` ```
## storageStatistics.getSystemSize<sup>9+</sup>
## storagestatistics.getSystemSize<sup>9+</sup>
getSystemSize(): Promise&lt;number&gt; getSystemSize(): Promise&lt;number&gt;
...@@ -389,25 +403,27 @@ Asynchronously obtains the system space. This API uses a promise to return the r ...@@ -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 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 | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system space obtained.| | Promise&lt;number&gt; | Promise used to return the system space obtained.|
- Example **Example**
```js ```js
storagestatistics.getSystemSize().then(function(number){ storageStatistics.getSystemSize().then(function(number){
console.info("getSystemSize successfully:"+ number); console.info("getSystemSize successfully:"+ number);
}).catch(function(err){ }).catch(function(err){
console.info("getSystemSize failed with error:"+ err); console.info("getSystemSize failed with error:"+ err);
}); });
``` ```
## storagestatistics.getSystemSize<sup>9+</sup> ## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback:AsyncCallback&lt;number&gt;):void getSystemSize(callback:AsyncCallback&lt;number&gt;):void
...@@ -417,28 +433,28 @@ Asynchronously obtains the system space. This API uses a callback to return the ...@@ -417,28 +433,28 @@ Asynchronously obtains the system space. This API uses a callback to return the
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **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 | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.| | callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
- Example **Example**
```js ```js
storagestatistics.getSystemSize(function(error, number){ storageStatistics.getSystemSize(function(error, number){
// Do something. // Do something.
console.info("getSystemSize successfully:"+ number); console.info("getSystemSize successfully:"+ number);
}); });
``` ```
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string): Promise&lt;StorageStats&gt; ## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result. 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 ...@@ -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 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| | Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- | | ---------- | ------ | ---- | ---- |
| userId | string | No | User ID.<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.| | userId | string | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.|
- Example **Example**
```js ```js
let userId = ""; let userId = "";
storagestatistics.getUserStorageStats(userId).then(function(StorageStats){ storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){ }).catch(function(err){
console.info("getUserStorageStats failed with error:"+ err); console.info("getUserStorageStats failed with error:"+ err);
}); });
``` ```
## storagestatistics.getUserStorageStats<sup>9+</sup> ## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string, callback:AsyncCallback&lt;StorageStats&gt;):void getUserStorageStats(userId: number, callback:AsyncCallback&lt;StorageStats&gt;):void
Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result. 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 ...@@ -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 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 | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | string | No | User ID.<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. | | userId | string | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes | Callback invoked to return the information obtained.| | callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes | Callback invoked to return the information obtained.|
- Example **Example**
```js ```js
storagestatistics.getUserStorageStats(userId, function(error, StorageStats){ let userId = "";
storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
// Do something. // Do something.
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}); });
``` ```
## StorageStats<sup>9+</sup> ## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Attributes
This is a system API and cannot be called by third-party applications.
### Attributes
| Name | Type | Description | | Name | Type | Description |
| --------- | ------ | -------------- | | --------- | ------ | -------------- |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册