// Check whether the result set of the obtained files is undefined. If yes, the API call fails.
if(fetchFileResult==undefined){
console.error('Failed to get fetchFileResult: '+error);
console.error('get fetchFileResult failed with error: '+error);
return;
}
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('Failed to get count from fetchFileResult: count: '+count);
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('Failed to get count from fetchFileResult: count: '+count);
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
Opens this file asset. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> Currently, the write operations are mutually exclusive. After the write operation is complete, you must call **close** to release the resource.
**NOTE**: When a file is opened in 'w' mode, the returned FD cannot be read. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
...
...
@@ -1222,12 +1250,12 @@ async function example() {
Opens this file asset. This API uses a promise to return the result.
> **NOTE**
>
> Currently, the write operations are mutually exclusive. After the write operation is complete, you must call **close** to release the resource.
**NOTE**: When a file is opened in 'w' mode, the returned FD cannot be read. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
...
...
@@ -1266,13 +1292,11 @@ async function example() {
Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
Obtains the next file asset in the result set. This API uses a promise to return the result.
> **NOTE**
>
> Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
| DATE_ADDED | "date_added" | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | "date_modified" | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
| DATE_TAKEN | "date_taken" | Date when the file (photo) was taken. The value is the number of seconds elapsed since the Epoch time. |
| TITLE | "title" | Title in the file. |
| ARTIST | "artist" | Artist of the file. |
| AUDIOALBUM | "audio_album" | Audio album. |
| DURATION | "duration" | Duration, in ms. |
| WIDTH | "width" | Image width, in pixels. |
| HEIGHT | "height" | Image height, in pixels. |
| ORIENTATION | "orientation" | Image display direction (clockwise rotation angle, for example, 0, 90, and 180, in degrees).|
| ALBUM_ID | "bucket_id" | ID of the album to which the file belongs. |
| ALBUM_NAME | "bucket_display_name" | Name of the album to which the file belongs. |
| ID | 'file_id' | File ID. |
| RELATIVE_PATH | 'relative_path' | Relative public directory of the file. |
| MIME_TYPE | 'mime_type' | Extended file attributes, such as image/, video/, and file/*. |
| MEDIA_TYPE | 'media_type' | Media type. |
| SIZE | 'size' | File size, in bytes. |
| DATE_ADDED | 'date_added' | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | 'date_modified' | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
| DATE_TAKEN | 'date_taken' | Date when the file (photo) was taken. The value is the number of seconds elapsed since the Epoch time. |
| TITLE | 'title' | Title in the file. |
| ARTIST | 'artist' | Artist of the file. |
| AUDIOALBUM | 'audio_album' | Audio album. |
| DURATION | 'duration' | Duration, in ms. |
| WIDTH | 'width' | Image width, in pixels. |
| HEIGHT | 'height' | Image height, in pixels. |
| ORIENTATION | 'orientation' | Image display direction (clockwise rotation angle, for example, 0, 90, and 180, in degrees).|
| ALBUM_ID | 'bucket_id' | ID of the album to which the file belongs. |
| ALBUM_NAME | 'bucket_display_name' | Name of the album to which the file belongs. |
## DirectoryType<sup>8+</sup>
...
...
@@ -2559,9 +2623,9 @@ Describes options for fetching media files.
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array<string> | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " ASC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + ' ASC'<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + ' DESC'|
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
...
@@ -33,7 +31,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback\<number\> | Yes| Callback used to return the published reminder's ID.|
| callback | AsyncCallback<number> | Yes| Callback used to return the published reminder's ID.|
**Error codes**
...
...
@@ -45,12 +43,11 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| 1700002 | The number of reminders exceeds the limit. |
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
...
@@ -85,7 +80,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<number\> | Promise used to return the published reminder's ID.|
| Promise<number> | Promise used to return the published reminder's ID.|
**Error codes**
...
...
@@ -97,12 +92,11 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| 1700002 | The number of reminders exceeds the limit. |
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
...
...
@@ -218,7 +206,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)\>\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
| callback | AsyncCallback<Array<[ReminderRequest](#reminderrequest)>> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
**Error codes**
...
...
@@ -230,7 +218,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
...
...
@@ -279,7 +266,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[ReminderRequest](#reminderrequest)\>\> | Promise used to return an array of all valid reminders set by the current application.|
| Promise<Array<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
**Error codes**
...
...
@@ -291,7 +278,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| repeatMonths | Array\<number\> | No| Month in which the reminder repeats.|
| repeatDays | Array\<number\> | No| Date on which the reminder repeats.|
| repeatMonths | Array<number> | No| Month in which the reminder repeats.|
| repeatDays | Array<number> | No| Date on which the reminder repeats.|
## ReminderRequestAlarm
...
...
@@ -671,7 +646,7 @@ Defines a reminder for an alarm.
| -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| daysOfWeek | Array\<number\> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
| daysOfWeek | Array<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
## ReminderRequestTimer
...
...
@@ -696,8 +671,8 @@ Sets the time information for a calendar reminder.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| year | number | Yes| Year.|
| month | number | Yes| Month.|
| day | number | Yes| Date.|
| hour | number | Yes| Hour.|
| minute | number | Yes| Minute.|
| second | number | No| Second.|
| month | number | Yes| Month. The value ranges from 1 to 12.|
| day | number | Yes| Day. The value ranges from 1 to 31.|
| hour | number | Yes| Hour. The value ranges from 0 to 23.|
| minute | number | Yes| Minute. The value ranges from 0 to 59.|
| second | number | No| Second. The value ranges from 0 to 59.|