提交 ebcafad1 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 7d18c4c3
# 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 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&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.
**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&lt;string&gt; | Promise used to return the result. An error code is returned. |
| Type | Description |
| --------------------- | -------------- |
| Promise&lt;string&gt; | 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&lt;string&gt;): 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&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | 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&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 |
| -------- | --------------------------- | ---- | ---------------------------- |
| type | 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. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| 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.|
- 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&lt;number&gt;
show(uri:string, type:string):Promise&lt;void&gt;
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&lt;void&gt; | Promise used to return the result. An error code is returned. |
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;void&gt; | 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&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.
**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&lt;void&gt; | 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&lt;void&gt; | 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
});
```
......@@ -3,7 +3,7 @@
> **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 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&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.
**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**.|
**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&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.
**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&lt;void&gt; | 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&lt;string&gt;
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&lt;string&gt;): 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**
......
......@@ -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&lt;number&gt;
......@@ -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&lt;number&gt; | 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&lt;number&gt;):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&lt;number&gt; | 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&lt;number&gt;
......@@ -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&lt;number&gt; | 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&lt;number&gt;):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&lt;number&gt; | 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.getBundleStats<sup>9+</sup>
## storageStatistics.getBundleStats<sup>9+</sup>
getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
......@@ -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&lt;[Bundlestats](#bundlestats)&gt; | 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.getBundleStats<sup>9+</sup>
## storageStatistics.getBundleStats<sup>9+</sup>
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
**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&lt;[Bundlestats](#bundlestats)&gt; | 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.getCurrentBundleStats<sup>9+</sup>
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise<BundleStats>
getCurrentBundleStats(): Promise&lt;BundleStats&gt;
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&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
- Example
**Example**
```js
let bundleStats = await storageStatistics.getCurrentBundleStats();
let bundleStats = storageStatistics.getCurrentBundleStats();
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.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Parameters
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | 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));
});
```
## BundleStats<sup>9+</sup>
**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.getTotalSize<sup>9+</sup>
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise<number>
getTotalSize(): Promise&lt;number&gt;
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&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
- Example
**Example**
```js
let number = await storageStatistics.getTotalSize();
let number = storageStatistics.getTotalSize();
console.info("getTotalSize successfully:"+ JSON.stringify(number));
```
## storagestatistics.getTotalSize<sup>9+</sup>
## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback<number>): void
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.
......@@ -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&lt;number&gt; | 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.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.
......@@ -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&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
- Example
**Example**
```js
let number = await storageStatistics.getFreeSize();
let number = storageStatistics.getFreeSize();
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.
......@@ -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&lt;number&gt; | 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.getSystemSize<sup>9+</sup>
## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(): Promise&lt;number&gt;
......@@ -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&lt;number&gt; | 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.getSystemSize<sup>9+</sup>
## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback:AsyncCallback&lt;number&gt;):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&lt;number&gt; | 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.getUserStorageStats<sup>9+</sup>
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string): Promise&lt;StorageStats&gt;
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.
......@@ -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.<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 |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | 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.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.
......@@ -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.<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.|
- 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));
});
```
## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Attributes
This is a system API and cannot be called by third-party applications.
### Attributes
| Name | Type | Description |
| --------- | ------ | -------------- |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册