@@ -231,7 +231,7 @@ You should override **onDestroy** to delete widget data.
...
@@ -231,7 +231,7 @@ You should override **onDestroy** to delete widget data.
}
}
```
```
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
For details about the persistence method, see [Lightweight Data Store Development](../database/database-storage-guidelines.md).
Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
>- 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.
>- 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**.
## Modules to Import
## Modules to Import
```js
```js
...
@@ -20,7 +21,7 @@ Obtains information about the files in the first-level directory in asynchronous
...
@@ -20,7 +21,7 @@ Obtains information about the files in the first-level directory in asynchronous
- Parameters
- Parameters
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value
- Return value
...
@@ -30,17 +31,17 @@ Obtains information about the files in the first-level directory in asynchronous
...
@@ -30,17 +31,17 @@ Obtains information about the files in the first-level directory in asynchronous
- Example
- Example
```js
```js
filemanager.getRoot().then((fileInfo)=>{
filemanager.getRoot().then((fileInfo)=>{
if(Array.isArray(fileInfo)){
if(Array.isArray(fileInfo)){
for(vari=0;i<fileInfo.length;i++){
for(vari=0;i<fileInfo.length;i++){
console.log(JSON.Stringify(fileInfo))
console.log(JSON.Stringify(fileInfo))
}
}
}
}
}).catch((err)=>{
}).catch((err)=>{
console.log(err)
console.log(err)
});
});
```
```
## filemanager.getRoot
## filemanager.getRoot
...
@@ -54,20 +55,20 @@ Obtains information about the files in the first-level directory in asynchronous
...
@@ -54,20 +55,20 @@ Obtains information about the files in the first-level directory in asynchronous
| dev | [DevInfo](#devinfo) | No | Device name. The default value is **local**, which is the only value supported.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, 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. |
- Example
- Example
```js
```js
filemanager.getRoot((err,fileInfo)=>{
filemanager.getRoot((err,fileInfo)=>{
if(Array.isArray(fileInfo)){
if(Array.isArray(fileInfo)){
for(vari=0;i<fileInfo.length;i++){
for(vari=0;i<fileInfo.length;i++){
console.log(JSON.Stringify(fileInfo))
console.log(JSON.Stringify(fileInfo))
}
}
}
}
})
});
```
```
## filemanager.listFile
## filemanager.listFile
...
@@ -80,11 +81,9 @@ Obtains information about the files in the second-level directory in asynchronou
...
@@ -80,11 +81,9 @@ Obtains information about the files in the second-level directory in asynchronou
- Parameters
- Parameters
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | string | Yes| URI of the directory to query.|
| path | string | Yes| URI of the directory to query.|
| dev | [DevInfo](#devinfo) | Yes| Device name. The default value is **local**, which is the only value supported.|
| type | string | Yes| Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| offset | number | No| Start position from which the files are to query.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, 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.|
| count | number | No| Number of files to query.|
- Return value
- Return value
...
@@ -95,25 +94,28 @@ Obtains information about the files in the second-level directory in asynchronou
...
@@ -95,25 +94,28 @@ Obtains information about the files in the second-level directory in asynchronou
- Error
- Error
| Error Info| Error Code|Description|
| Error Info| Error Code|Description|
| -- | --- | -- |
| -- | --- | -- |
|No such file or directory | 2 | The directory or file of the specified URI does not exist.|
|No such file or directory | 2 | The directory or file of the specified URI does not exist.|
|No such process | 3 | Failed to obtain the FMS service.|
|No such process | 3 | Failed to obtain the FMS service.|
|Not a directory | 20 | The object specified by the URI is not a directory.|
|Not a directory | 20 | The object specified by the URI is not a directory.|
```js
- Example
// Obtain all files in the directory.
// Call listFile() and getRoot() to obtain file URIs.
```js
letmedia_path=file.uri
// Obtain all files in the directory.
filemanager.listFile(media_path,"file")
// Call listFile() and getRoot() to obtain file URIs.
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | string | Yes | URI of the directory to query. |
| path | string | Yes | URI of the directory to query. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| offset | number | No| Start position from which the files are to query.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, 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.|
| count | number | No| 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. |
Creates a file in the specified path in asynchronous mode. This method uses a promise to return the result.
Creates a file in the specified path in asynchronous mode. This method uses a promise to return the result.
...
@@ -165,7 +167,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
...
@@ -165,7 +167,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| filename | string | Yes| Name of the file to create.|
| filename | string | Yes| Name of the file to create.|
| path | string | Yes| URI of the file to create.|
| path | string | Yes| URI of the file to create.|
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, see [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
- Return value
- Return value
...
@@ -181,18 +183,20 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
...
@@ -181,18 +183,20 @@ Creates a file in the specified path in asynchronous mode. This method uses a pr
| No such process | 3 | Failed to obtain the FMS service.|
| No such process | 3 | Failed to obtain the FMS service.|
| Not a directory | 20 | The object specified by the URI is not a directory.|
| Not a directory | 20 | The object specified by the URI is not a directory.|
```js
- Example
// Create a file.
letmedia_path=file.uri// Obtain the file URI using listFile() and getRoot().
```js
letname="xxx.jpg"// File to be saved.
// Create a file.
filemanager.createFile(media_path,name)
letmedia_path=file.uri// Obtain the file URI using listFile() and getRoot().
.then((uri)=>{
letname="xxx.jpg"// File to be saved.
// The URI of the file created is returned.
filemanager.createFile(media_path,name)
})
.then((uri)=>{
.catch((err)=>{
// The URI of the file created is returned.
})
.catch((err)=>{
console.log(err)
console.log(err)
})
});
```
```
## filemanager.createFile
## filemanager.createFile
...
@@ -208,7 +212,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
...
@@ -208,7 +212,7 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
| filename | string | Yes | Name of the file to create. |
| filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| path | string | Yes | URI of the file to create. |
| dev | [DevInfo](#devinfo) | No| Device name. The default value is **local**, which is the only value supported.|
| options | Object | No| The options are as follows:<br>- **dev**: Device type. For details, 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. |
- Error
- Error
...
@@ -220,16 +224,18 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
...
@@ -220,16 +224,18 @@ Creates a file in the specified path in asynchronous mode. This method uses a ca
| No such process | 3 | Failed to obtain the FMS service. |
| No such process | 3 | Failed to obtain the FMS service. |
| Not a directory | 20 | The object specified by the URI is not a directory.|
| Not a directory | 20 | The object specified by the URI is not a directory.|
```js
- Example
// Create a file.
// Call listFile() and getRoot() to obtain the file URI.
```js
letmedia_path=file.uri
// Create a file.
// File to be saved.
// Call listFile() and getRoot() to obtain the file URI.
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md).
>
> - 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
```
import bluetooth from '@system.bluetooth';
```
## bluetooth.startBLEScan(OBJECT)
Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
| interval | number | No| Interval for reporting device information, in milliseconds. The default value is **0**, which means to report the detected device immediately and report other information at the given interval.|
| success | Function | No| Called when the operation is successful.|
| fail | Function | No| Called when the operation fails.|
| complete | Function | No| Called when the execution is complete.|
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.data.storage`](js-apis-data-storage.md) instead.
>
> - The APIs of this module are no longer maintained since API Version 6. You are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
>
>
> - The initial APIs of this module are supported since API version 3. 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 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -18,19 +19,19 @@ import storage from '@system.storage';
...
@@ -18,19 +19,19 @@ import storage from '@system.storage';