@@ -636,7 +636,7 @@ Sets the **RdbPredicates** to match the specified string.
...
@@ -636,7 +636,7 @@ Sets the **RdbPredicates** to match the specified string.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.|
| field | string | Yes| Column name in the database table.|
| value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. ***** indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
| value | string | Yes| Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. ? indicates a single digit or character.|
@@ -7,7 +7,7 @@ Lightweight storage provides applications with data processing capability and al
...
@@ -7,7 +7,7 @@ Lightweight storage provides applications with data processing capability and al
>
>
> 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.
>
>
>
## Modules to Import
## Modules to Import
...
@@ -22,15 +22,15 @@ import dataStorage from '@ohos.data.storage';
...
@@ -22,15 +22,15 @@ import dataStorage from '@ohos.data.storage';
>- 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**.
>- 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
## Modules to Import
```js
```js
...
@@ -81,8 +83,8 @@ Obtains information about the second-level album or files in asynchronous mode.
...
@@ -81,8 +83,8 @@ Obtains information about the second-level album or files in asynchronous mode.
- Parameters
- Parameters
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| path | string | Yes| URI of the directory to query.|
| path | promise<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**.|
| 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>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- **offset**: position to start the query. The value is a number.<br>- **count**: number of files to query.|
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- **offset**: position to start the query. The value is a number.<br>- **count**: number of files to query.|
- Return value
- Return value
...
@@ -128,8 +130,8 @@ Obtains information about the second-level album or files in asynchronous mode.
...
@@ -128,8 +130,8 @@ Obtains information about the second-level album or files in asynchronous mode.
| path | string | Yes | URI of the directory to query. |
| path | promise<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**.|
| 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>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- **offset**: position to start the query. The value is a number.<br>- **count**: number of files to query.|
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- **offset**: position to start the query. The value is a number.<br>- **count**: number of files to query.|
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
- Error
- Error
...
@@ -156,7 +158,7 @@ Obtains information about the second-level album or files in asynchronous mode.
...
@@ -156,7 +158,7 @@ Obtains information about the second-level album or files in asynchronous mode.
Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result.
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
...
@@ -165,8 +167,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a promi
- Parameters
- Parameters
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| filename | string | Yes| Name of the file to create.|
| filename | promise<string>| Yes| Name of the file to create.|
| path | string | Yes| URI of the file to create.|
| path | promise<string>| Yes| URI of the file to create.|
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value
- Return value
...
@@ -209,8 +211,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
...
@@ -209,8 +211,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
| filename | string | Yes | Name of the file to create. |
| filename | promise<string> | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| path | promise<string> | Yes | URI of the file to create. |
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| options | Object | No| The options are as follows:<br>- **dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | Yes | Callback invoked to return the file information obtained. |
...
@@ -246,9 +248,9 @@ Defines the file information returned by **getRoot()** or **listFile()**.
...
@@ -246,9 +248,9 @@ Defines the file information returned by **getRoot()** or **listFile()**.
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| --- | -- | -- | -- | -- |
| --- | -- | -- | -- | -- |
| name | string | Yes| No| File name.|
| name | promise<string>| Yes| No| File name.|
| path | string | Yes| No| URI of the file.|
| path | promise<string>| Yes| No| URI of the file.|
| type | string | Yes| No| File type.|
| type | promise<string>| Yes| No| File type.|
| size | number | Yes| No| File size.|
| size | number | Yes| No| File size.|
| addedTime | number | Yes| No| Time when the file was scanned to the database.|
| addedTime | number | Yes| No| Time when the file was scanned to the database.|
| modifiedTime | number | Yes| No| Time when the file was modified.|
| modifiedTime | number | Yes| No| Time when the file was modified.|
...
@@ -263,4 +265,4 @@ Defines the device type.
...
@@ -263,4 +265,4 @@ Defines the device type.
| Name| Type | Readable| Writable| Description |
| Name| Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | -------- |
| ------ | ------ | ---- | ---- | -------- |
| name | string | Yes | Yes | Device name.|
| name | promise<string>| Yes | Yes | Device name.|
> 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 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
## Modules to Import
```js
```js
...
@@ -11,11 +13,11 @@ import statfs from '@ohos.statfs';
...
@@ -11,11 +13,11 @@ import statfs from '@ohos.statfs';
## Guidelines
## 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
```js
letpath=dir+"xxx.txt";
letpath=dir+"xxx.txt";
...
@@ -25,7 +27,7 @@ let path = dir + "xxx.txt";
...
@@ -25,7 +27,7 @@ let path = dir + "xxx.txt";
getFreeBytes(path:string):Promise<number>
getFreeBytes(path:string):Promise<number>
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.
> - 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 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
## Modules to Import
...
@@ -130,7 +133,7 @@ Asynchronously obtains the available space of the specified volume. This API use
...
@@ -130,7 +133,7 @@ Asynchronously obtains the available space of the specified volume. This API use
@@ -68,7 +68,7 @@ Sets the value in the cache based on the specified key.
...
@@ -68,7 +68,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to set.|
| key | string | Yes| Key of the data to set.|
| value | string | Yes| New value to set. The maximum length is 128 bytes.|
| value | string | Yes| New value to set. The length must be less than 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.|
| success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.set()** is complete.|
| complete | Function | No| Called when **storage.set()** is complete.|
> - The initial APIs of this module are supported since API version 9.
> - 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
## Modules to Import
...
@@ -15,7 +18,7 @@ import volumemanager from "@ohos.volumeManager";
...
@@ -15,7 +18,7 @@ import volumemanager from "@ohos.volumeManager";
In this example, the app requires the **ohos.permission.PERMISSION1** and **ohos.permission.PERMISSION2** permissions to implement core functions.
In this example, the app requires the **ohos.permission.PERMISSION1** and **ohos.permission.PERMISSION2** permissions to implement core functions.
...
@@ -26,7 +26,7 @@ The table below lists only the API used in this guide. For more information, see
...
@@ -26,7 +26,7 @@ The table below lists only the API used in this guide. For more information, see
### config.json
### config.json
Declare the permissions required by the app one by one in the **config.json** file. The app cannot obtain a permission if it is not declared in the **config.json** file.
Declare the permissions required by the app one by one in the **config.json** file. The app can obtain permissions that have been declared in the **config.json** file.
**Description of config.json**
**Description of config.json**
...
@@ -107,7 +107,7 @@ In addition to declaring all the permissions in the **config.json** file, you mu
...
@@ -107,7 +107,7 @@ In addition to declaring all the permissions in the **config.json** file, you mu
After the permissions are declared, the system grants the system_grant permission during the installation of the app. The user_grant permission must be authorized by the user.
After the permissions are declared, the system grants the system_grant permission during the installation of the app. The user_grant permission must be authorized by the user.
Therefore, before invoking the API protected by the **ohos.permission.PERMISSION2 permission**, the app needs to verify whether it has the permission.
Therefore, before allowing the app to call the API protected by the **ohos.permission.PERMISSION2** permission, the system needs to verify whether the app has the permission to do so.
If the verification result indicates that the app has the permission, the app can access the target API. Otherwise, the app needs to request user authorization and then proceeds based on the authorization result. For details, see [Access Control Overview](accesstoken-overview.md).
If the verification result indicates that the app has the permission, the app can access the target API. Otherwise, the app needs to request user authorization and then proceeds based on the authorization result. For details, see [Access Control Overview](accesstoken-overview.md).
...
@@ -119,34 +119,26 @@ If the verification result indicates that the app has the permission, the app ca
...
@@ -119,34 +119,26 @@ If the verification result indicates that the app has the permission, the app ca
The procedure is as follows:
The procedure is as follows:
1. Obtain the caller's identity tokenId.
1. Obtain the ability context.
2. Determine the permission to be verified. In this example, the permission is **permissionNameUser**.
2. Call **requestPermissionsFromUser** to verify whether the app has required permissions.
3. Call **verifyAccessToken** to verify the permissions of the caller.
3. Proceed based on the permission verification result.
4. Proceed based on the permission verification result.
> For details about how to use **requestPermissionsFromUser**, see [API Reference](../reference/apis/js-apis-ability-context.md#abilitycontextrequestpermissionsfromuser).
> For details about how to use **requestPermissionsFromUser**, see [API Reference](../reference/apis/js-apis-ability-context.md#abilitycontextrequestpermissionsfromuser).