提交 5b6c789f 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 48dd5d93
......@@ -20,7 +20,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the stage model.
> **NOTE**
> This API is deprecated since API Version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead.
> This API is deprecated since API version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -62,7 +62,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the FA model.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -88,8 +88,8 @@ Obtains file assets (also called files). This API uses an asynchronous callback
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
> - This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -161,8 +161,8 @@ Obtains file assets. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
> - This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -234,7 +234,8 @@ on(type: 'deviceChange'&#124;'albumChange'&#124;'imageChange'&#124;'audioChange'
Subscribes to the media library changes. This API uses a callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [registerChange](js-apis-photoAccessHelper.md#registerchange) instead.
>
> This API is deprecated since API version 9. Use [registerChange](js-apis-photoAccessHelper.md#registerchange) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -260,7 +261,8 @@ off(type: 'deviceChange'&#124;'albumChange'&#124;'imageChange'&#124;'audioChange
Unsubscribes from the media library changes. This API uses a callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [unRegisterChange](js-apis-photoAccessHelper.md#unregisterchange) instead.
>
> This API is deprecated since API version 9. Use [unRegisterChange](js-apis-photoAccessHelper.md#unregisterchange) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -287,7 +289,7 @@ Creates a media asset. This API uses an asynchronous callback to return the resu
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset) instead.
> - This API is deprecated since API version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -329,7 +331,7 @@ Creates a media asset. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset-1) instead.
> - This API is deprecated since API version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset-1) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -375,7 +377,8 @@ Deletes a file asset. This API uses a promise to return the result.
Before calling this API, call [FileAsset.trash](#trash8) to move the file to the trash. Otherwise, the file fails to be deleted.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-3) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-3) instead.
**System API**: This is a system API.
......@@ -429,7 +432,8 @@ Deletes a file asset. This API uses an asynchronous callback to return the resul
Before calling this API, call [FileAsset.trash](#trash8) to move the file to the trash. Otherwise, the file fails to be deleted.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-2) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-2) instead.
**System API**: This is a system API.
......@@ -478,7 +482,8 @@ getPublicDirectory(type: DirectoryType, callback: AsyncCallback&lt;string&gt;):
Obtains a user directory. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -509,7 +514,8 @@ getPublicDirectory(type: DirectoryType): Promise&lt;string&gt;
Obtains a user directory. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -550,7 +556,7 @@ Obtains albums. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -590,7 +596,7 @@ Obtains albums. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -633,7 +639,8 @@ Releases this **MediaLibrary** instance.
Call this API when you no longer need to use the APIs in the **MediaLibrary** instance.
> **NOTE**
> This API is deprecated since API Version 9. Use [release](js-apis-photoAccessHelper.md#release) instead.
>
> This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -659,7 +666,7 @@ Releases this **MediaLibrary** instance.
Call this API when you no longer need to use the APIs in the **MediaLibrary** instance.
> **NOTE**
> This API is deprecated since API Version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead.
> This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -684,7 +691,7 @@ Stores a media asset. This API uses an asynchronous callback to return the URI o
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. Use [save](js-apis-file-picker.md#save-1) instead.
> - This API is deprecated since API version 9. Use [save](js-apis-file-picker.md#save-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -722,7 +729,7 @@ Stores a media asset. This API uses a promise to return the URI of the media ass
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. Use [save](js-apis-file-picker.md#save) instead.
> - This API is deprecated since API version 9. Use [save](js-apis-file-picker.md#save) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -758,12 +765,12 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCallback&lt;void&gt;): void
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
Starts image preview, with the first image to preview specified. This API can be used to preview a local image with the specified index (**file://**) or all online images (**https://**). It uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -771,7 +778,7 @@ Starts image preview, with the first image to preview specified. This API can be
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **'https://'** or **'datashare://'**.|
| images | Array&lt;string&gt; | Yes | Images to preview. You can preview a local image (**file://**) or all online images (**https://**).|
| index | number | Yes | Index of the first image to preview. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
......@@ -802,12 +809,12 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (error) => {
startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
Starts image preview. This API can be used to preview the first local image (**file://**) or all online images (**https://**). It uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -815,7 +822,7 @@ Starts image preview. This API can be used to preview local images whose URIs st
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **'https://'** or **'datashare://'**.|
| images | Array&lt;string&gt; | Yes | Images to preview. You can preview a local image (**file://**) or all online images (**https://**).|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example**
......@@ -844,12 +851,12 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (error) => {
startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&gt;
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
Starts image preview, with the first image to preview specified. This API can be used to preview a local image with the specified index (**file://**) or all online images (**https://**). It uses a promise to return the execution result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -857,7 +864,7 @@ Starts image preview, with the first image to preview specified. This API can be
| Name | Type | Mandatory | Description |
| ------ | ------------------- | ---- | ---------------------------------------- |
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **'https://'** or **'datashare://'**.|
| images | Array&lt;string&gt; | Yes | Images to preview. You can preview a local image (**file://**) or all online images (**https://**).|
| index | number | No | Index of the first image to preview. If this parameter is not specified, the default value **0** is used. |
**Return value**
......@@ -896,7 +903,7 @@ Starts media selection. This API uses an asynchronous callback to return the URI
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. Use [select](js-apis-file-picker.md#select-1) instead.
> - This API is deprecated since API version 9. Use [select](js-apis-file-picker.md#select-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -933,7 +940,7 @@ Starts media selection. This API uses a promise to return the URIs of the select
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. Use [select](js-apis-file-picker.md#select) instead.
> - This API is deprecated since API version 9. Use [select](js-apis-file-picker.md#select) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -971,7 +978,8 @@ getActivePeers(): Promise\<Array\<PeerInfo>>;
Obtains information about online peer devices. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -1008,7 +1016,8 @@ getActivePeers(callback: AsyncCallback\<Array\<PeerInfo>>): void;
Obtains information about online peer devices. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -1043,7 +1052,8 @@ getAllPeers(): Promise\<Array\<PeerInfo>>;
Obtains information about all peer devices. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -1080,7 +1090,8 @@ getAllPeers(callback: AsyncCallback\<Array\<PeerInfo>>): void;
Obtains information about all peer devices. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -1116,7 +1127,7 @@ Provides APIs for encapsulating file asset attributes.
>
> - The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> - Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
> - This API is deprecated since API Version 9. Use [PhotoAsset](js-apis-photoAccessHelper.md#photoasset) instead.
> - This API is deprecated since API version 9. Use [PhotoAsset](js-apis-photoAccessHelper.md#photoasset) instead.
### Attributes
......@@ -1153,7 +1164,8 @@ isDirectory(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this file asset is a directory. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1196,7 +1208,8 @@ isDirectory():Promise&lt;boolean&gt;
Checks whether this file asset is a directory. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1238,7 +1251,7 @@ Commits the modification on the file metadata to the database. This API uses an
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify) instead.
> - This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify) instead.
> - Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1280,7 +1293,7 @@ Commits the modification on the file asset to the database. This API uses a prom
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-1) instead.
> - This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-1) instead.
> Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1319,9 +1332,11 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void
Opens this file asset. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [open](js-apis-photoAccessHelper.md#open) instead.
**NOTE**<br>If a file is opened in 'w' mode, the returned file descriptor (FD) cannot be used to read the file. 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 close the file.
>
> - This API is deprecated since API version 9. Use [open](js-apis-photoAccessHelper.md#open) instead.
>
> - If a file is opened in 'w' mode, the returned file descriptor (FD) cannot be used to read the file. 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 close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
......@@ -1359,9 +1374,10 @@ open(mode: string): Promise&lt;number&gt;
Opens this file asset. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [open](js-apis-photoAccessHelper.md#open-1) instead.
**NOTE**<br>If a file is opened in 'w' mode, the returned FD cannot be used to read the file. 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 close the file.
>
> - This API is deprecated since API version 9. Use [open](js-apis-photoAccessHelper.md#open-1) instead.
> - If a file is opened in 'w' mode, the returned FD cannot be used to read the file. 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 close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
......@@ -1402,7 +1418,8 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void
Closes a file. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#close) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#close) instead.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
......@@ -1451,7 +1468,8 @@ close(fd: number): Promise&lt;void&gt;
Closes a file. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#close-1) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#close-1) instead.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
......@@ -1503,7 +1521,8 @@ getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
Obtains the thumbnail of this file asset. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1546,7 +1565,8 @@ getThumbnail(size: Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
Obtains the file thumbnail of the given size. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail-1) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail-1) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1591,7 +1611,8 @@ getThumbnail(size?: Size): Promise&lt;image.PixelMap&gt;
Obtains the file thumbnail of the given size. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail-2) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#getThumbnail-2) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1639,7 +1660,8 @@ favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void
Favorites or unfavorites this file asset. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [setFavorite](js-apis-photoAccessHelper.md#setfavorite) instead.
>
> This API is deprecated since API version 9. Use [setFavorite](js-apis-photoAccessHelper.md#setfavorite) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1683,7 +1705,8 @@ favorite(isFavorite: boolean): Promise&lt;void&gt;
Favorites or unfavorites this file asset. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [setFavorite](js-apis-photoAccessHelper.md#setfavorite-1) instead.
>
> This API is deprecated since API version 9. Use [setFavorite](js-apis-photoAccessHelper.md#setfavorite-1) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1730,7 +1753,8 @@ isFavorite(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this file asset is favorited. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1773,7 +1797,8 @@ isFavorite():Promise&lt;boolean&gt;
Checks whether this file asset is favorited. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1816,7 +1841,8 @@ Moves this file asset to the trash. This API uses an asynchronous callback to re
Files in the trash are not actually deleted. You can set **isTrash** to **false** to restore the files from the trash.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteAssets) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteAssets) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1862,7 +1888,8 @@ Moves this file asset to the trash. This API uses a promise to return the result
Files in the trash are not actually deleted. You can set **isTrash** to **false** to restore the files from the trash.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteAssets-1) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteAssets-1) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -1909,7 +1936,8 @@ isTrash(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this file asset is in the trash. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1952,7 +1980,8 @@ isTrash():Promise&lt;boolean&gt;
Checks whether this file asset is in the trash. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -1991,7 +2020,8 @@ async function example() {
Provides APIs to manage the file retrieval result.
> **NOTE**
> This API is deprecated since API Version 9. Use [FetchResult](js-apis-photoAccessHelper.md#fetchresult) instead.
>
> This API is deprecated since API version 9. Use [FetchResult](js-apis-photoAccessHelper.md#fetchresult) instead.
### getCount<sup>7+</sup>
......@@ -2000,7 +2030,8 @@ getCount(): number
Obtains the total number of files in the result set.
> **NOTE**
> This API is deprecated since API Version 9. Use [getCount](js-apis-photoAccessHelper.md#getcount) instead.
>
> This API is deprecated since API version 9. Use [getCount](js-apis-photoAccessHelper.md#getcount) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2035,7 +2066,8 @@ isAfterLast(): boolean
Checks whether the cursor is in the last row of the result set.
> **NOTE**
> This API is deprecated since API Version 9. Use [isAfterLast](js-apis-photoAccessHelper.md#isafterlast) instead.
>
> This API is deprecated since API version 9. Use [isAfterLast](js-apis-photoAccessHelper.md#isafterlast) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2078,7 +2110,8 @@ close(): void
Releases and invalidates this **FetchFileResult** instance. After this instance is released, the APIs in this instance cannot be invoked.
> **NOTE**
> This API is deprecated since API Version 9. Use [close](js-apis-photoAccessHelper.md#close) instead.
>
> This API is deprecated since API version 9. Use [close](js-apis-photoAccessHelper.md#close) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2105,7 +2138,8 @@ getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void
Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getFirstObject](js-apis-photoAccessHelper.md#getfirstobject) instead.
>
> This API is deprecated since API version 9. Use [getFirstObject](js-apis-photoAccessHelper.md#getfirstobject) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2145,7 +2179,8 @@ getFirstObject(): Promise&lt;FileAsset&gt;
Obtains the first file asset in the result set. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getFirstObject](js-apis-photoAccessHelper.md#getfirstobject-1) instead.
>
> This API is deprecated since API version 9. Use [getFirstObject](js-apis-photoAccessHelper.md#getfirstobject-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2185,7 +2220,7 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal
> **NOTE**
>
> - Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to check that the cursor does not point to the last file asset in the result set.
> - This API is deprecated since API Version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject) instead.
> - This API is deprecated since API version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2232,7 +2267,7 @@ Obtains the next file asset in the result set. This API uses a promise to return
> **NOTE**
>
> - Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to check that the cursor does not point to the last file asset in the result set.
> - This API is deprecated since API Version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject-1) instead.
> - This API is deprecated since API version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2274,7 +2309,8 @@ getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void
Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getLastObject](js-apis-photoAccessHelper.md#getlastobject) instead.
>
> This API is deprecated since API version 9. Use [getLastObject](js-apis-photoAccessHelper.md#getlastobject) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2314,7 +2350,8 @@ getLastObject(): Promise&lt;FileAsset&gt;
Obtains the last file asset in the result set. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getLastObject](js-apis-photoAccessHelper.md#getlastobject-1) instead.
>
> This API is deprecated since API version 9. Use [getLastObject](js-apis-photoAccessHelper.md#getlastobject-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2352,7 +2389,8 @@ getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void
Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getObjectByPosition](js-apis-photoAccessHelper.md#getobjectbyposition) instead.
>
> This API is deprecated since API version 9. Use [getObjectByPosition](js-apis-photoAccessHelper.md#getobjectbyposition) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2393,7 +2431,8 @@ getPositionObject(index: number): Promise&lt;FileAsset&gt;
Obtains a file asset with the specified index in the result set. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getObjectByPosition](js-apis-photoAccessHelper.md#getobjectbyposition-1) instead.
>
> This API is deprecated since API version 9. Use [getObjectByPosition](js-apis-photoAccessHelper.md#getobjectbyposition-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2437,7 +2476,8 @@ getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void
Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getAllObjects](js-apis-photoAccessHelper.md#getallobjects) instead.
>
> This API is deprecated since API version 9. Use [getAllObjects](js-apis-photoAccessHelper.md#getallobjects) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2479,7 +2519,8 @@ getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;
Obtains all the file assets in the result set. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getAllObjects](js-apis-photoAccessHelper.md#getallobjects-1) instead.
>
> This API is deprecated since API version 9. Use [getAllObjects](js-apis-photoAccessHelper.md#getallobjects-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2517,7 +2558,8 @@ async function example() {
Provides APIs to manage albums.
> **NOTE**
> This API is deprecated since API Version 9. Use [Album](js-apis-photoAccessHelper.md#album) instead.
>
> This API is deprecated since API version 9. Use [Album](js-apis-photoAccessHelper.md#album) instead.
### Attributes
......@@ -2540,7 +2582,8 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void
Commits the modification on the album attributes to the database.
> **NOTE**
> This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-2) instead.
>
> This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-2) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -2581,7 +2624,8 @@ commitModify(): Promise&lt;void&gt;
Commits the modification on the album attributes to the database.
> **NOTE**
> This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-3) instead.
>
> This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-3) instead.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -2620,7 +2664,8 @@ getFileAssets(callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains the file assets in this album. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
>
> This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -2664,7 +2709,8 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe
Obtains the file assets in this album based on specified conditions. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
>
> This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -2713,7 +2759,8 @@ async function example() {
Obtains the file assets in this album based on specified conditions. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
>
> This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
**Required permissions**: ohos.permission.READ_MEDIA
......@@ -2763,7 +2810,8 @@ async function example() {
Defines information about a registered device.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -2781,7 +2829,8 @@ Defines information about a registered device.
Enumerates media types.
> **NOTE**
> This API is deprecated since API Version 9. Use [PhotoType](js-apis-photoAccessHelper.md#phototype) instead.
>
> This API is deprecated since API version 9. Use [PhotoType](js-apis-photoAccessHelper.md#phototype) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2799,7 +2848,7 @@ Enumerates key file information.
> **NOTE**
>
> - The **bucket_id** field may change after file rename or movement. Therefore, you must obtain the field again before using it.
> - This API is deprecated since API Version 9. Use [PhotoKeys](js-apis-photoAccessHelper.md#photokeys) instead.
> - This API is deprecated since API version 9. Use [PhotoKeys](js-apis-photoAccessHelper.md#photokeys) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2830,7 +2879,8 @@ Enumerates key file information.
Enumerates directory types.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2848,7 +2898,8 @@ Enumerates directory types.
Enumerates the device types.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System API**: This is a system API.
......@@ -2869,15 +2920,16 @@ Enumerates the device types.
Defines the options for fetching media files.
> **NOTE**
> This API is deprecated since API Version 9. Use [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) instead.
>
> This API is deprecated since API version 9. Use [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------- | ---- | ---- | ------------------------------------------------------------ |
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names when files are fetched. 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 when files are fetched. <br/>Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' + mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array&lt;string&gt; | Yes | Yes | Values of the conditions specified 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. <br/>Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + ' ASC'<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + ' DESC' |
| uri<sup>8+</sup> | string | Yes | Yes | URI of the file. |
| networkId<sup>8+</sup> | string | Yes | Yes | Network ID of the registered device. |
| extendArgs<sup>8+</sup> | string | Yes | Yes | Extended parameters for fetching the files. Currently, no extended parameters are available. |
......@@ -2887,7 +2939,8 @@ Defines the options for fetching media files.
Defines the image size.
> **NOTE**
> This API is deprecated since API Version 9. Use [image.Size](js-apis-image.md#size) instead.
>
> This API is deprecated since API version 9. Use [image.Size](js-apis-image.md#size) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -2901,26 +2954,28 @@ Defines the image size.
Defines the media asset option.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable| Writable| Description |
| ------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
| src | string | Yes | Yes | Application sandbox oath of the local file. |
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | Yes | Yes | Custom path of media assets, for example, **Pictures/**. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: **'Pictures/'**<br> Default path of videos: **'Videos/'**<br> Default path of audios: **'Audios/'**<br> Default path of documents: **'Documents/'**|
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file/*'. |
| relativePath | string | Yes | Yes | Customized path of media assets, for example, **Pictures/**. If this parameter is unspecified, the default paths of media assets are as follows:<br> Default path of images: **'Pictures/'**<br> Default path of videos: **'Videos/'**<br> Default path of audio files: **'Audios/'**<br> Default path of documents: **'Documents/'** |
## MediaSelectOption
Defines the media selection option.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable| Writable| Description |
| ----- | ------ | ---- | ---- | -------------------- |
| type | 'image' &#124; 'video' &#124; 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| count | number | Yes | Yes | Maximum number of media assets that can be selected. The value starts from 1, which indicates that one media asset can be selected. |
| count | number | Yes | Yes | Maximum number of media assets that can be selected.<br/>The value **1** means to select only one media asset; the value greater than **1** means to select multiple media assets. |
......@@ -21,18 +21,20 @@ For applications developed based on earlier versions, pay attention to the itera
| medialibrary | **function** getAlbums(options: MediaFetchOptions): Promise&lt;Array&lt;Album&gt;&gt; | Interface compatibility changed |
| medialibrary | **function** FileAsset.commitModify(callback: AsyncCallback&lt;void&gt;): void | Interface compatibility changed |
| medialibrary | **function** FileAsset.commitModify(): Promise&lt;void&gt; | Interface compatibility changed |
| medialibrary | **function** FileAsset.deleteAsset(uri: string, callback: AsyncCallback&lt;void&gt;): void | Interface compatibility changed |
| medialibrary | **function** FileAsset.deleteAsset(uri: string): Promise&lt;void&gt; | Interface compatibility changed |
**Adaptation Guide**
**getFileAssets**
From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. See the following example:
From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. The following is an example of incorrect use of the APIs.
1. Use [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Use [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the file fetching options.
3. Use [getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
1. Call [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Call [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the file fetching options.
3. Call [getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
**Incorrect code example**:
**Example (incorrect)**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
......@@ -58,7 +60,7 @@ async function example() {
Use **getFileAssets()** as follows:
**Correct code example**:
**Example (correct)**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
......@@ -84,17 +86,17 @@ async function example() {
**createAsset**
From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed as an album.
Since the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed as an album.
**getAlbums**
From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**, and the values of **ALBUM_NAME** can be **Camera** and **Screenshots** only. See the following example:
Since the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**, and the values of **ALBUM_NAME** can be **Camera** and **Screenshots** only. The following is an example of incorrect use of the APIs.
1. Use [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Use [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the album fetching options.
3. Use [getAlbums](../../../application-dev/reference/apis/js-apis-medialibrary.md#getalbums7) to obtain albums.
**Incorrect code example**:
**Example (incorrect)**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
......@@ -119,7 +121,7 @@ async function example() {
The following example shows how to obtain **Camera** and **Screenshots** albums:
**Correct code example**:
**Example (correct)**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
......@@ -145,3 +147,40 @@ async function example() {
**FileAsset.commitModify**
The **orientation** attribute for audio is deleted from the SDK of API version 10. When **commitModify** is used, the **orientation** attribute of audio resources cannot be modified.
**FileAsset.deleteAsset**
The change has resolved a known issue of the file deletion mechanism. This issue may cause a system application to permanently delete a file that is not in the trash using **MediaLibrary.deleteAsset**.
The correct procedure for a system application to permanently delete a file is as follows:
1. Call [getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
2. Call [FileAsset.trash](../../../application-dev/reference/apis/js-apis-medialibrary.md#trash8) to move the file to the trash.
3. Call [MediaLibrary.deleteAsset](../../../application-dev/reference/apis/js-apis-medialibrary.md#deleteasset8) to permanently delete the file.
**Example (correct)**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const fileAsset = await fetchFileResult.getFirstObject();
// Delete the file (move it to the trash of Gallery).
await fileAsset.trash(true);
// Delete the file from the system permanently.
await media.deleteAsset(fileAsset.uri);
} catch (err) {
console.error('Failed to delete asset permanently from system, error: ' + err);
}
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册