提交 de0a2a7e 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 92787162
# User File Access and Management
>![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
>**NOTE**<br/>
>
>- The initial APIs of this module are supported since API version 8. 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 are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**.
This module provides service APIs for accessing and managing user files. It interworks with the underlying file management services to implement media library and external card management, and provides capabilities for applications to query and create user files.
## Modules to Import
```js
......@@ -81,8 +83,8 @@ Obtains information about the second-level album or files in asynchronous mode.
- Parameters
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| path | string | Yes| URI of the directory to query.|
| type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | promise<string>| Yes| URI of the directory to query.|
| type | promise<string>| Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
- Return value
......@@ -128,8 +130,8 @@ Obtains information about the second-level album or files in asynchronous mode.
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | URI of the directory to query. |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | promise<string> | Yes | URI of the directory to query. |
| type | promise<string> | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
- Error
......@@ -156,7 +158,7 @@ Obtains information about the second-level album or files in asynchronous mode.
## filemanager.createFile
filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result.
......@@ -165,8 +167,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a promi
- Parameters
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| filename | string | Yes| Name of the file to create.|
| path | string | Yes| URI of the file to create.|
| filename | promise<string>| Yes| Name of the file to create.|
| path | promise<string>| Yes| URI of the file to create.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value
......@@ -209,8 +211,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| filename | promise<string> | Yes | Name of the file to create. |
| path | promise<string> | Yes | URI of the file to create. |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
......@@ -246,9 +248,9 @@ Defines the file information returned by **getRoot()** or **listFile()**.
| Name| Type| Readable| Writable| Description|
| --- | -- | -- | -- | -- |
| name | string | Yes| No| File name.|
| path | string | Yes| No| URI of the file.|
| type | string | Yes| No| File type.|
| name | promise<string>| Yes| No| File name.|
| path | promise<string>| Yes| No| URI of the file.|
| type | promise<string>| Yes| No| File type.|
| size | number | Yes| No| File size.|
| addedTime | number | Yes| No| Time when the file was scanned to the database.|
| modifiedTime | number | Yes| No| Time when the file was modified.|
......@@ -263,4 +265,4 @@ Defines the device type.
| Name| Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | -------- |
| name | string | Yes | Yes | Device name.|
| name | promise<string>| Yes | Yes | Device name.|
# statfs
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
This module provides information related to the file system. It provides JS APIs to obtain the total number of bytes and the number of idle bytes of the file system.
## Modules to Import
```js
......@@ -11,11 +13,11 @@ import statfs from '@ohos.statfs';
## Guidelines
Before using this module to perform operations on a file or directory, obtain the absolute path of the file or directory. 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).
Absolute file or directory path = Application directory + File name or directory name
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 absolute path of the file is as follows:
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";
......@@ -25,7 +27,7 @@ let path = dir + "xxx.txt";
getFreeBytes(path:string):Promise&lt;number&gt;
Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a promise to return the result.
Obtains the number of free bytes of the specified file system in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
......@@ -56,7 +58,7 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
getFreeBytes(path:string, callback:AsyncCallback&lt;number&gt;): void
Obtains the number of free bytes of the specified file system in asynchronous mode. This method uses a callback to return the result.
Obtains the number of free bytes of the specified file system in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
......@@ -79,7 +81,7 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
getTotalBytes(path: string): Promise&lt;number&gt;
Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a promise to return the result.
Obtains the total number of bytes of the specified file system in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
......@@ -110,7 +112,7 @@ Obtains the total number of bytes of the specified file system in asynchronous m
getTotalBytes(path: string, callback: AsyncCallback&lt;number&gt;): void
Obtains the total number of bytes of the specified file system in asynchronous mode. This method uses a callback to return the result.
Obtains the total number of bytes of the specified file system in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
......
# App Storage Statistics
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
This module provides functions to obtain storage statistics, including the space of built-in and plug-in memory cards, statistics of application data by type, and application data.
## Modules to Import
......@@ -130,7 +133,7 @@ Asynchronously obtains the available space of the specified volume. This API use
getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
Asynchronously obtains app information. This API uses a promise to return the result.
Asynchronously obtains application information. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
......@@ -138,13 +141,13 @@ Asynchronously obtains app information. This API uses a promise to return the re
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the app.|
| packageName | string | Yes | Bundle name of the application.|
- Return value
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the app information.|
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the application data obtained.|
- Example
......@@ -161,7 +164,7 @@ Asynchronously obtains app information. This API uses a promise to return the re
getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains app information. This API uses a callback to return the result.
Asynchronously obtains application information. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
......@@ -169,8 +172,8 @@ Asynchronously obtains app information. This API uses a callback to return the r
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the app.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the app information.|
| packageName | string | Yes | Bundle name of the application.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback used to return the application information obtained.|
- Example
......@@ -186,10 +189,10 @@ Asynchronously obtains app information. This API uses a callback to return the r
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
### Attributes
### Attribute
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize<sup>9+</sup> | number | Size of the app. |
| cacheSize<sup>9+</sup> | number | Cache size of the app. |
| dataSize<sup>9+</sup> | number | Total data size of the app.|
| appSize<sup>9+</sup> | number | Size of the application. |
| cacheSize<sup>9+</sup> | number | Cache size of the application. |
| dataSize<sup>9+</sup> | number | Total data size of the application.|
# Volume Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 9.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
This module provides APIs to implement volume and disk management, including obtaining volume information, mounting and unmounting volumes, partitioning disks, and formatting volumes.
## Modules to Import
......@@ -15,7 +18,7 @@ import volumemanager from "@ohos.volumeManager";
getAllVolumes(): Promise&lt;Array&lt;Volume&gt;&gt;
Asynchronously obtains information about all available volumes. This method uses a promise to return the result.
Asynchronously obtains information about all available volumes. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -37,7 +40,7 @@ Asynchronously obtains information about all available volumes. This method uses
getAllVolumes(callback: AsyncCallback&lt;Array&lt;Volume&gt;&gt;): void
Asynchronously obtains information about all available volumes. This method uses a callback to return the result.
Asynchronously obtains information about all available volumes. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -61,7 +64,7 @@ Asynchronously obtains information about all available volumes. This method uses
mount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously mounts a volume. This method uses a promise to return the result.
Asynchronously mounts a volume. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -90,7 +93,7 @@ Asynchronously mounts a volume. This method uses a promise to return the result.
mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result.
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -114,7 +117,7 @@ Asynchronously obtains the available space of the specified volume. This method
unmount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously unmounts a volume. This method uses a promise to return the result.
Asynchronously unmounts a volume. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -143,7 +146,7 @@ Asynchronously unmounts a volume. This method uses a promise to return the resul
unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously unmounts a volume. This method uses a callback to return the result.
Asynchronously unmounts a volume. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册