• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interface (PhotoAccessHelper)
2
3<!--Kit: Media Library Kit-->
4<!--Subsystem: Multimedia-->
5<!--Owner: @xuchangda;@yixiaoff-->
6<!--SE: @guxinggang;@liweilu1-->
7<!--TSE: @wangbeibei;@xchaosioda-->
8
9> **NOTE**
10>
11> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
12
13## Modules to Import
14
15```ts
16import { photoAccessHelper } from '@kit.MediaLibraryKit';
17```
18
19## getAssets
20
21getAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;PhotoAsset&gt;&gt;): void
22
23Obtains image and video assets. This API uses an asynchronous callback to return the result.
24
25**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
26
27**Required permissions**: ohos.permission.READ_IMAGEVIDEO
28
29When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
30
31**Parameters**
32
33| Name  | Type                    | Mandatory| Description                     |
34| -------- | ------------------------ | ---- | ------------------------- |
35| options  | [FetchOptions](arkts-apis-photoAccessHelper-i.md#fetchoptions)        | Yes  | Retrieval options.             |
36| callback |  AsyncCallback&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)&gt;&gt; | Yes  | Callback used to return the image and video assets obtained.|
37
38**Error codes**
39
40For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
41
42In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
43
44| ID| Error Message|
45| -------- | ---------------------------------------- |
46| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
47| 201     | Permission denied.         |
48| 13900020     | Invalid argument.         |
49| 14000011       | System inner fail.         |
50
51**Example**
52
53For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
54
55```ts
56import { dataSharePredicates } from '@kit.ArkData';
57
58async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
59  console.info('getAssets');
60  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
61  let fetchOptions: photoAccessHelper.FetchOptions = {
62    fetchColumns: [],
63    predicates: predicates
64  };
65
66  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
67    if (fetchResult !== undefined) {
68      console.info('fetchResult success');
69      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
70      if (photoAsset !== undefined) {
71        console.info('photoAsset.displayName : ' + photoAsset.displayName);
72      }
73    } else {
74      console.error(`fetchResult fail with error: ${err.code}, ${err.message}`);
75    }
76  });
77}
78```
79
80## getAssets
81
82getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
83
84Obtains image and video assets. This API uses a promise to return the result.
85
86**Atomic service API**: This API can be used in atomic services since API version 20.
87
88**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
89
90**Required permissions**: ohos.permission.READ_IMAGEVIDEO
91
92When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
93
94**Parameters**
95
96| Name | Type               | Mandatory| Description            |
97| ------- | ------------------- | ---- | ---------------- |
98| options | [FetchOptions](arkts-apis-photoAccessHelper-i.md#fetchoptions)   | Yes  | Retrieval options.    |
99
100**Return value**
101
102| Type                       | Description          |
103| --------------------------- | -------------- |
104| Promise&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)&gt;&gt; | Promise used to return the image and video assets obtained.|
105
106**Error codes**
107
108For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
109
110In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
111
112| ID| Error Message|
113| -------- | ---------------------------------------- |
114| 201     | Permission denied.         |
115| 13900020     | Invalid argument.         |
116| 14000011       | System inner fail.         |
117
118**Example**
119
120For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
121
122```ts
123import { dataSharePredicates } from '@kit.ArkData';
124
125async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
126  console.info('getAssets');
127  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
128  let fetchOptions: photoAccessHelper.FetchOptions = {
129    fetchColumns: [],
130    predicates: predicates
131  };
132  try {
133    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
134    if (fetchResult !== undefined) {
135      console.info('fetchResult success');
136      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
137      if (photoAsset !== undefined) {
138        console.info('photoAsset.displayName :' + photoAsset.displayName);
139      }
140    }
141  } catch (err) {
142    console.error(`getAssets failed, error: ${err.code}, ${err.message}`);
143  }
144}
145```
146
147## getBurstAssets<sup>12+</sup>
148
149getBurstAssets(burstKey: string, options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
150
151Obtains burst assets. This API uses a promise to return the result.
152
153**Atomic service API**: This API can be used in atomic services since API version 20.
154
155**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
156
157**Required permissions**: ohos.permission.READ_IMAGEVIDEO
158
159**Parameters**
160
161| Name | Type               | Mandatory| Description            |
162| ------- | ------------------- | ---- | ---------------- |
163| burstKey | string   | Yes  | UUID of a set of burst photos (**BURST_KEY** of [PhotoKeys](arkts-apis-photoAccessHelper-e.md#photokeys)). The value is a string of 36 characters.|
164| options | [FetchOptions](arkts-apis-photoAccessHelper-i.md#fetchoptions)   | Yes  | Retrieval options.    |
165
166**Return value**
167
168| Type                       | Description          |
169| --------------------------- | -------------- |
170| Promise&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)&gt;&gt; | Promise used to return the result.|
171
172**Error codes**
173
174For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
175
176| ID| Error Message|
177| -------- | ---------------------------------------- |
178| 201   | Permission denied.         |
179| 14000011       | Internal system error.         |
180
181**Example**
182
183For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
184
185```ts
186import { dataSharePredicates } from '@kit.ArkData';
187
188async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
189  console.info('getBurstAssets');
190  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
191  let fetchOptions: photoAccessHelper.FetchOptions = {
192    fetchColumns: [],
193    predicates: predicates
194  };
195  // burstKey is a 36-bit UUID, which can be obtained from photoAccessHelper.PhotoKeys.
196  let burstKey: string = "e719d696-09fa-44f8-8e9e-ec3f215aa62a";
197  try {
198    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await
199      phAccessHelper.getBurstAssets(burstKey, fetchOptions);
200    if (fetchResult !== undefined) {
201      console.info('fetchResult success');
202      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
203      if (photoAsset !== undefined) {
204        console.info('photoAsset.displayName :' + photoAsset.displayName);
205      }
206    }
207  } catch (err) {
208    console.error(`getBurstAssets failed, error: ${err.code}, ${err.message}`);
209  }
210}
211```
212
213## createAsset
214
215createAsset(photoType: PhotoType, extension: string, options: CreateOptions, callback: AsyncCallback&lt;string&gt;): void
216
217Creates an image or video asset with the specified file type, file name extension, and options. This API uses an asynchronous callback to return the result.
218
219If you do not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component or an authorization pop-up. For details, see [Saving Media Assets](../../media/medialibrary/photoAccessHelper-savebutton.md).
220
221**Atomic service API**: This API can be used in atomic services since API version 11.
222
223**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
224
225**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
226
227**Parameters**
228
229| Name  | Type                    | Mandatory| Description                     |
230| -------- | ------------------------ | ---- | ------------------------- |
231| photoType  | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
232| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
233| options  | [CreateOptions](arkts-apis-photoAccessHelper-i.md#createoptions)        | Yes  | Options used for creation. Currently, only **title** is supported, for example, **{title: 'testPhoto'}**.<br>**NOTE**: If other options are passed, the configuration does not take effect.     |
234| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback used to return the URI of the created image or video asset.|
235
236**Error codes**
237
238For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
239
240In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
241
242| ID| Error Message|
243| -------- | ---------------------------------------- |
244| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
245| 201     | Permission denied.         |
246| 13900020     | Invalid argument.         |
247| 14000011       | System inner fail.         |
248
249**Example**
250
251For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
252
253```ts
254async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
255  console.info('createAssetDemo');
256  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
257  let extension:string = 'jpg';
258  let options: photoAccessHelper.CreateOptions = {
259    title: 'testPhoto'
260  }
261  phAccessHelper.createAsset(photoType, extension, options, (err, uri) => {
262    if (uri !== undefined) {
263      console.info('createAsset uri' + uri);
264      console.info('createAsset successfully');
265    } else {
266      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
267    }
268  });
269}
270```
271
272## createAsset
273
274createAsset(photoType: PhotoType, extension: string, callback: AsyncCallback&lt;string&gt;): void
275
276Creates an image or video asset with the specified file type and file name extension. This API uses an asynchronous callback to return the result.
277
278If you do not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component or an authorization pop-up. For details, see [Saving Media Assets](../../media/medialibrary/photoAccessHelper-savebutton.md).
279
280**Atomic service API**: This API can be used in atomic services since API version 11.
281
282**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
283
284**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
285
286**Parameters**
287
288| Name  | Type                    | Mandatory| Description                     |
289| -------- | ------------------------ | ---- | ------------------------- |
290| photoType  | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
291| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
292| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback used to return the URI of the created image or video asset.|
293
294**Error codes**
295
296For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
297
298In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
299
300| ID| Error Message|
301| -------- | ---------------------------------------- |
302| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
303| 201     | Permission denied.         |
304| 13900020     | Invalid argument.         |
305| 14000011       | System inner fail.         |
306
307**Example**
308
309For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
310
311```ts
312async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
313  console.info('createAssetDemo');
314  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
315  let extension: string = 'jpg';
316  phAccessHelper.createAsset(photoType, extension, (err, uri) => {
317    if (uri !== undefined) {
318      console.info('createAsset uri' + uri);
319      console.info('createAsset successfully');
320    } else {
321      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
322    }
323  });
324}
325```
326
327## createAsset
328
329createAsset(photoType: PhotoType, extension: string, options?: CreateOptions): Promise&lt;string&gt;
330
331Creates an image or video asset with the specified file type, file name extension, and options. This API uses a promise to return the result.
332
333If you do not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component or an authorization pop-up. For details, see [Saving Media Assets](../../media/medialibrary/photoAccessHelper-savebutton.md).
334
335**Atomic service API**: This API can be used in atomic services since API version 11.
336
337**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
338
339**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
340
341**Parameters**
342
343| Name  | Type                    | Mandatory| Description                     |
344| -------- | ------------------------ | ---- | ------------------------- |
345| photoType  | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
346| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
347| options  | [CreateOptions](arkts-apis-photoAccessHelper-i.md#createoptions)        | No  | Options used for creation. Currently, only **title** is supported, for example, **{title: 'testPhoto'}**.<br>**NOTE**: If other options are passed, the configuration does not take effect.     |
348
349**Return value**
350
351| Type                       | Description          |
352| --------------------------- | -------------- |
353| Promise&lt;string&gt; | Promise used to return the URI of the created image or video asset.|
354
355**Error codes**
356
357For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
358
359In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
360
361| ID| Error Message|
362| -------- | ---------------------------------------- |
363| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
364| 201     | Permission denied.         |
365| 13900020     | Invalid argument.         |
366| 14000011       | System inner fail.         |
367
368**Example**
369
370For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
371
372```ts
373async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
374  console.info('createAssetDemo');
375  try {
376    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
377    let extension: string = 'jpg';
378    let options: photoAccessHelper.CreateOptions = {
379      title: 'testPhoto'
380    }
381    let uri: string = await phAccessHelper.createAsset(photoType, extension, options);
382    console.info('createAsset uri' + uri);
383    console.info('createAsset successfully');
384  } catch (err) {
385    console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
386  }
387}
388```
389
390## getAlbums
391
392getAlbums(type: AlbumType, subtype: AlbumSubtype, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
393
394Obtains albums based on the specified options and album type. This API uses an asynchronous callback to return the result.
395
396Before the operation, ensure that the albums to obtain exist.
397
398**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
399
400**Required permissions**: ohos.permission.READ_IMAGEVIDEO
401
402**Parameters**
403
404| Name  | Type                    | Mandatory| Description                     |
405| -------- | ------------------------ | ---- | ------------------------- |
406| type  | [AlbumType](arkts-apis-photoAccessHelper-e.md#albumtype)         | Yes  | Type of the album.             |
407| subtype  | [AlbumSubtype](arkts-apis-photoAccessHelper-e.md#albumsubtype)         | Yes  | Subtype of the album.             |
408| options  | [FetchOptions](arkts-apis-photoAccessHelper-i.md#fetchoptions)         | Yes  |  Retrieval options.             |
409| callback |  AsyncCallback&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[Album](arkts-apis-photoAccessHelper-Album.md)&gt;&gt; | Yes  | Callback used to return the result.|
410
411**Error codes**
412
413For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
414
415In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
416
417| ID| Error Message|
418| -------- | ---------------------------------------- |
419| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
420| 201     | Permission denied.         |
421| 13900020     | Invalid argument.         |
422| 14000011       | System inner fail.         |
423
424**Example**
425
426For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
427
428```ts
429import { dataSharePredicates } from '@kit.ArkData';
430
431async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
432  // Obtain the album named newAlbumName.
433  console.info('getAlbumsDemo');
434  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
435  predicates.equalTo('album_name', 'newAlbumName');
436  let fetchOptions: photoAccessHelper.FetchOptions = {
437    fetchColumns: [],
438    predicates: predicates
439  };
440  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions, async (err, fetchResult) => {
441    if (err) {
442      console.error(`getAlbumsCallback failed with err: ${err.code}, ${err.message}`);
443      return;
444    }
445    if (fetchResult === undefined) {
446      console.error('getAlbumsCallback fetchResult is undefined');
447      return;
448    }
449    let album = await fetchResult.getFirstObject();
450    console.info('getAlbumsCallback successfully, albumName: ' + album.albumName);
451    fetchResult.close();
452  });
453}
454```
455
456## getAlbums
457
458getAlbums(type: AlbumType, subtype: AlbumSubtype, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
459
460Obtains albums by type. This API uses an asynchronous callback to return the result.
461
462Before the operation, ensure that the albums to obtain exist.
463
464**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
465
466**Required permissions**: ohos.permission.READ_IMAGEVIDEO
467
468**Parameters**
469
470| Name  | Type                    | Mandatory| Description                     |
471| -------- | ------------------------ | ---- | ------------------------- |
472| type  | [AlbumType](arkts-apis-photoAccessHelper-e.md#albumtype)         | Yes  | Type of the album.             |
473| subtype  | [AlbumSubtype](arkts-apis-photoAccessHelper-e.md#albumsubtype)         | Yes  | Subtype of the album.             |
474| callback |  AsyncCallback&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[Album](arkts-apis-photoAccessHelper-Album.md)&gt;&gt; | Yes  | Callback used to return the result.|
475
476**Error codes**
477
478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
479
480In API version 13 and earlier versions, if the caller does not have the required permission, error code 13900012 is returned. Starting from API version 14, the same situation raises error code 201.
481
482| ID| Error Message|
483| -------- | ---------------------------------------- |
484| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
485| 201     | Permission denied.         |
486| 13900020     | Invalid argument.         |
487| 14000011       | System inner fail.         |
488
489**Example**
490
491For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
492
493```ts
494async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
495  // Obtain the system album VIDEO, which is preset by default.
496  console.info('getAlbumsDemo');
497  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.VIDEO, async (err, fetchResult) => {
498    if (err) {
499      console.error(`getAlbumsCallback failed with err: ${err.code}, ${err.message}`);
500      return;
501    }
502    if (fetchResult === undefined) {
503      console.error('getAlbumsCallback fetchResult is undefined');
504      return;
505    }
506    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
507    console.info('getAlbumsCallback successfully, albumUri: ' + album.albumUri);
508    fetchResult.close();
509  });
510}
511```
512
513## getAlbums
514
515getAlbums(type: AlbumType, subtype: AlbumSubtype, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
516
517Obtains albums based on the specified options and album type. This API uses a promise to return the result.
518
519Before the operation, ensure that the albums to obtain exist.
520
521**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
522
523**Required permissions**: ohos.permission.READ_IMAGEVIDEO
524
525**Parameters**
526
527| Name  | Type                    | Mandatory| Description                     |
528| -------- | ------------------------ | ---- | ------------------------- |
529| type  | [AlbumType](arkts-apis-photoAccessHelper-e.md#albumtype)         | Yes  | Type of the album.             |
530| subtype  | [AlbumSubtype](arkts-apis-photoAccessHelper-e.md#albumsubtype)         | Yes  | Subtype of the album.             |
531| options  | [FetchOptions](arkts-apis-photoAccessHelper-i.md#fetchoptions)         | No  |  Retrieval options. If this parameter is not specified, the albums are obtained based on the album type by default.             |
532
533**Return value**
534
535| Type                       | Description          |
536| --------------------------- | -------------- |
537| Promise&lt;[FetchResult](arkts-apis-photoAccessHelper-FetchResult.md)&lt;[Album](arkts-apis-photoAccessHelper-Album.md)&gt;&gt; | Promise used to return the result.|
538
539**Error codes**
540
541For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
542
543If error code 13900012 is returned, follow the instructions provided in [Before You Start](../../media/medialibrary/photoAccessHelper-preparation.md).
544
545| ID| Error Message|
546| -------- | ---------------------------------------- |
547| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
548| 201     | Permission denied.         |
549| 13900020     | Invalid argument.         |
550| 14000011       | System inner fail.         |
551
552**Example**
553
554For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
555
556```ts
557import { dataSharePredicates } from '@kit.ArkData';
558import { BusinessError } from '@kit.BasicServicesKit';
559
560async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
561  // Obtain the album named newAlbumName.
562  console.info('getAlbumsDemo');
563  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
564  predicates.equalTo('album_name', 'newAlbumName');
565  let fetchOptions: photoAccessHelper.FetchOptions = {
566    fetchColumns: [],
567    predicates: predicates
568  };
569  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions).then( async (fetchResult) => {
570    if (fetchResult === undefined) {
571      console.error('getAlbumsPromise fetchResult is undefined');
572      return;
573    }
574    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
575    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
576    fetchResult.close();
577  }).catch((err: BusinessError) => {
578    console.error(`getAlbumsPromise failed with err: ${err.code}, ${err.message}`);
579  });
580}
581```
582
583## registerChange
584
585registerChange(uri: string, forChildUris: boolean, callback: Callback&lt;ChangeData&gt;) : void
586
587Registers listening for the specified URI. This API uses a callback to return the result.
588
589**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
590
591**Parameters**
592
593| Name   | Type                                       | Mandatory| Description                                                        |
594| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
595| uri       | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](arkts-apis-photoAccessHelper-e.md#defaultchangeuri).|
596| forChildUris | boolean                                     | Yes  | Whether to perform fuzzy listening.<br>If **uri** is the URI of an album, the value **true** means to listen for the changes of the files in the album; the value **false** means to listen for the changes of the album only.<br>If **uri** is the URI of a photoAsset, there is no difference between **true** and false for **forChildUris**.<br>If **uri** is **DefaultChangeUri**, **forChildUris** must be set to **true**. If **forChildUris** is false, the URI cannot be found and no message can be received.|
597| callback  | Callback&lt;[ChangeData](arkts-apis-photoAccessHelper-i.md#changedata)&gt; | Yes  | Callback used to return [ChangeData](arkts-apis-photoAccessHelper-i.md#changedata). **NOTE**: Multiple callback listeners can be registered for a URI. You can use [unRegisterChange](#unregisterchange) to unregister all listeners for the URI or a specified callback listener.|
598
599**Error codes**
600
601For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
602
603If error code 13900012 is returned, follow the instructions provided in [Before You Start](../../media/medialibrary/photoAccessHelper-preparation.md).
604
605| ID| Error Message|
606| -------- | ---------------------------------------- |
607| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
608| 13900012     | Permission denied.         |
609| 13900020     | Invalid argument.         |
610
611**Example**
612
613For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
614
615```ts
616import { dataSharePredicates } from '@kit.ArkData';
617
618async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
619  console.info('registerChangeDemo');
620  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
621  let fetchOptions: photoAccessHelper.FetchOptions = {
622    fetchColumns: [],
623    predicates: predicates
624  };
625  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
626  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
627  if (photoAsset !== undefined) {
628    console.info('photoAsset.displayName : ' + photoAsset.displayName);
629  }
630  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
631      console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
632    //file had changed, do something.
633  }
634  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
635      console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
636    //file had changed, do something.
637  }
638  // Register onCallback1.
639  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
640  // Register onCallback2.
641  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
642
643  await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [photoAsset]);
644}
645```
646
647## unRegisterChange
648
649unRegisterChange(uri: string, callback?: Callback&lt;ChangeData&gt;): void
650
651Unregisters listening for the specified URI. Multiple callbacks can be registered for a URI for listening. You can use this API to unregister the listening of the specified callbacks or all callbacks.
652
653**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
654
655**Parameters**
656
657| Name  | Type                                       | Mandatory| Description                                                        |
658| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
659| uri      | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](arkts-apis-photoAccessHelper-e.md#defaultchangeuri).|
660| callback | Callback&lt;[ChangeData](arkts-apis-photoAccessHelper-i.md#changedata)&gt; | No  | Callback to unregister. If this parameter is not specified, all the callbacks for listening for the URI will be canceled. **NOTE**: The specified callback unregistered will not be invoked when the data changes.|
661
662**Error codes**
663
664For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
665
666If error code 13900012 is returned, follow the instructions provided in [Before You Start](../../media/medialibrary/photoAccessHelper-preparation.md).
667
668| ID| Error Message|
669| -------- | ---------------------------------------- |
670| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
671| 13900012     | Permission denied.         |
672| 13900020     | Invalid argument.         |
673
674**Example**
675
676For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
677
678```ts
679import { dataSharePredicates } from '@kit.ArkData';
680
681async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
682  console.info('offDemo');
683  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
684  let fetchOptions: photoAccessHelper.FetchOptions = {
685    fetchColumns: [],
686    predicates: predicates
687  };
688  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
689  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
690  if (photoAsset !== undefined) {
691    console.info('photoAsset.displayName : ' + photoAsset.displayName);
692  }
693  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
694    console.info('onCallback1 on');
695  }
696  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
697    console.info('onCallback2 on');
698  }
699  // Register onCallback1.
700  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
701  // Register onCallback2.
702  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
703  // Unregister the listening of onCallback1.
704  phAccessHelper.unRegisterChange(photoAsset.uri, onCallback1);
705  await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [photoAsset]);
706}
707```
708
709## applyChanges<sup>11+</sup>
710
711applyChanges(mediaChangeRequest: MediaChangeRequest): Promise&lt;void&gt;
712
713Applies media changes. This API uses a promise to return the result.
714
715**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
716
717If you do not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component or an authorization pop-up. For details, see [Saving Media Assets](../../media/medialibrary/photoAccessHelper-savebutton.md).
718
719**Atomic service API**: This API can be used in atomic services since API version 11.
720
721**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
722
723**Parameters**
724
725| Name  | Type                    | Mandatory| Description                     |
726| -------- | ------------------------ | ---- | ------------------------- |
727| mediaChangeRequest  | [MediaChangeRequest](arkts-apis-photoAccessHelper-i.md#mediachangerequest11)  | Yes |  Request for asset changes or album changes.|
728
729**Return value**
730
731| Type                                   | Description             |
732| --------------------------------------- | ----------------- |
733| Promise&lt;void&gt;| Promise that returns no value.|
734
735**Error codes**
736
737For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
738
739| ID| Error Message|
740| -------- | ---------------------------------------- |
741| 201   | Permission denied.         |
742| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
743| 14000011  | System inner fail.     |
744
745**Example**
746
747This API depends on the [MediaChangeRequest](arkts-apis-photoAccessHelper-i.md#mediachangerequest11) object. For details about the sample code, see the examples of [MediaAssetChangeRequest](arkts-apis-photoAccessHelper-MediaAssetChangeRequest.md) and [MediaAlbumChangeRequest](arkts-apis-photoAccessHelper-MediaAlbumChangeRequest.md).
748
749## release
750
751release(callback: AsyncCallback&lt;void&gt;): void
752
753Releases this PhotoAccessHelper instance. This API uses an asynchronous callback to return the result.
754
755Call this API when the APIs of the PhotoAccessHelper instance are no longer used.
756
757**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
758
759**Parameters**
760
761| Name  | Type                     | Mandatory| Description                |
762| -------- | ------------------------- | ---- | -------------------- |
763| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
764
765**Error codes**
766
767For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
768
769| ID| Error Message|
770| -------- | ---------------------------------------- |
771| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
772| 13900020     | Invalid argument.         |
773| 14000011       | System inner fail.         |
774
775**Example**
776
777For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
778
779```ts
780async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
781  console.info('releaseDemo');
782  phAccessHelper.release((err) => {
783    if (err !== undefined) {
784      console.error(`release failed. error: ${err.code}, ${err.message}`);
785    } else {
786      console.info('release ok.');
787    }
788  });
789}
790```
791
792## release
793
794release(): Promise&lt;void&gt;
795
796Releases this PhotoAccessHelper instance. This API uses a promise to return the result.
797
798Call this API when the APIs of the PhotoAccessHelper instance are no longer used.
799
800**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
801
802**Return value**
803
804| Type               | Description                             |
805| ------------------- | --------------------------------- |
806| Promise&lt;void&gt; | Promise that returns no value.|
807
808**Error codes**
809
810For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
811
812| ID| Error Message|
813| -------- | ---------------------------------------- |
814| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
815| 13900020     | Invalid argument.         |
816| 14000011       | System inner fail.         |
817
818**Example**
819
820For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
821
822```ts
823async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
824  console.info('releaseDemo');
825  try {
826    await phAccessHelper.release();
827    console.info('release ok.');
828  } catch (err) {
829    console.error(`release failed. error: ${err.code}, ${err.message}`);
830  }
831}
832```
833
834## showAssetsCreationDialog<sup>12+</sup>
835
836showAssetsCreationDialog(srcFileUris: Array&lt;string&gt;, photoCreationConfigs: Array&lt;PhotoCreationConfig&gt;): Promise&lt;Array&lt;string&gt;&gt;
837
838Shows the dialog box for the user to confirm whether to save the photos or videos. If the user agrees to save the images or videos, a list of URIs granted with the save permission is returned. The list takes effect permanently, and the application can write the images or videos based on the URIs. If the user refuses to save the images or videos, an empty list is returned. To display the application name in the dialog box, the API relies on the configuration of **label** and **icon** under **abilities** in the **module.json5** file. If they are not configured, no application name is displayed in the dialog box.
839
840> **NOTE**
841>
842> If the passed URI is a sandbox path, photos or videos can be saved but cannot be previewed.
843
844**Atomic service API**: This API can be used in atomic services since API version 12.
845
846**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
847
848**Parameters**
849
850| Name  | Type                                                                  | Mandatory| Description                     |
851| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
852| srcFileUris | Array&lt;string&gt; | Yes| [URIs](../../file-management/user-file-uri-intro.md#media-file-uri) of the images or videos to be saved to the media library.<br>**NOTE**<br>- A maximum of 100 images can be saved at a time.<br>- Only image and video URIs are supported.<br>- URIs cannot be manually constructed. You must call APIs to obtain them. For details, see [Obtaining a Media File URI](../../file-management/user-file-uri-intro.md#obtaining-a-media-file-uri). |
853| photoCreationConfigs | Array&lt;[PhotoCreationConfig](arkts-apis-photoAccessHelper-i.md#photocreationconfig12)&gt; | Yes| Configuration for saving the images or videos, including the file names. The value must be consistent with that of **srcFileUris**.|
854
855**Return value**
856
857| Type                                   | Description             |
858| --------------------------------------- | ----------------- |
859| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return a URI list. The URIs are granted with the permission for the application to write data. If the URIs fail to be generated, a batch creation error code will be returned.<br>The error code **-3006** means that there are invalid characters; **-2004** means that the image type does not match the file name extension; **-203** means that the file operation is abnormal.|
860
861**Error codes**
862
863For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
864
865| ID| Error Message|
866| -------- | ---------------------------------------- |
867| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
868| 14000011 |  Internal system error. |
869
870**Example**
871
872For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
873
874```ts
875import { dataSharePredicates } from '@kit.ArkData';
876
877async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
878  console.info('ShowAssetsCreationDialogDemo.');
879
880  try {
881    // Obtain the sandbox URIs of the images or videos to be saved to the media library.
882    let srcFileUris: Array<string> = [
883      'file://fileUriDemo1' // The URI here is an example only.
884    ];
885    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
886      {
887        title: 'test2', // Optional.
888        fileNameExtension: 'jpg',
889        photoType: photoAccessHelper.PhotoType.IMAGE,
890        subtype: photoAccessHelper.PhotoSubtype.DEFAULT, // This parameter is optional.
891      }
892    ];
893    let desFileUris: Array<string> = await phAccessHelper.showAssetsCreationDialog(srcFileUris, photoCreationConfigs);
894    console.info('showAssetsCreationDialog success, data is ' + desFileUris);
895  } catch (err) {
896    console.error('showAssetsCreationDialog failed, errCode is ' + err.code + ', errMsg is ' + err.message);
897  }
898}
899```
900
901## createAssetWithShortTermPermission<sup>12+</sup>
902
903createAssetWithShortTermPermission(photoCreationConfig: PhotoCreationConfig): Promise&lt;string&gt;
904
905Creates an asset with a temporary permission of the given period. When this API is called by an application for the first time, a dialog box will be displayed for the user to confirm whether to save the asset. If the user agrees to save the asset, the asset instance will be created and the file URI granted with the save permission will be returned. The application can write the asset based on the URI
906within 5 minutes after the user agrees to save the asset. If the same application calls this API again within the 5 minutes, the authorized URI can be automatically returned without the need to display the conformation dialog box.
907
908**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
909
910**Required permissions**: ohos.permission.SHORT_TERM_WRITE_IMAGEVIDEO
911
912**Parameters**
913
914| Name  | Type                                                                  | Mandatory| Description                     |
915| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
916| photoCreationConfig | [PhotoCreationConfig](arkts-apis-photoAccessHelper-i.md#photocreationconfig12); | Yes| Configuration for saving a media asset (image or video) to the media library, including the file name.|
917
918**Return value**
919
920| Type                                   | Description             |
921| --------------------------------------- | ----------------- |
922| Promise&lt;string&gt; | Promise used to return the URI of the asset saved. The URIs are granted with the permission for the application to write data. If the URIs fail to be generated, a batch creation error code will be returned.<br>The error code **-3006** means that there are invalid characters; **-2004** means that the image type does not match the file name extension; **-203** means that the file operation is abnormal.|
923
924**Error codes**
925
926For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
927
928| ID| Error Message|
929| -------- | ---------------------------------------- |
930| 201 | Permission denied |
931| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
932| 14000011 |  Internal system error |
933
934**Example**
935
936For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
937
938```ts
939import { fileIo } from '@kit.CoreFileKit';
940
941async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
942    console.info('createAssetWithShortTermPermissionDemo.');
943
944    try {
945        let photoCreationConfig: photoAccessHelper.PhotoCreationConfig = {
946            title: '123456',
947            fileNameExtension: 'jpg',
948            photoType: photoAccessHelper.PhotoType.IMAGE,
949            subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
950        };
951
952        let resultUri: string = await phAccessHelper.createAssetWithShortTermPermission(photoCreationConfig);
953        let resultFile: fileIo.File = fileIo.openSync(resultUri, fileIo.OpenMode.READ_WRITE);
954        // Use the actual URI and file size.
955        let srcFile:  fileIo.File = fileIo.openSync("file://test.jpg", fileIo.OpenMode.READ_ONLY);
956        let bufSize: number = 2000000;
957        let readSize: number = 0;
958        let buf = new ArrayBuffer(bufSize);
959        let readLen = fileIo.readSync(srcFile.fd, buf, {
960            offset: readSize,
961            length: bufSize
962        });
963        if (readLen > 0) {
964            readSize += readLen;
965            fileIo.writeSync(resultFile.fd, buf, { length: readLen });
966        }
967        fileIo.closeSync(srcFile);
968        fileIo.closeSync(resultFile);
969    } catch (err) {
970        console.error('createAssetWithShortTermPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
971    }
972
973}
974```
975
976## requestPhotoUrisReadPermission<sup>14+</sup>
977
978requestPhotoUrisReadPermission(srcFileUris: Array&lt;string&gt;): Promise&lt;Array&lt;string&gt;&gt;
979
980<!--RP1--><!--RP1End-->Grants the save permission for URIs. This API uses a promise to return the result.
981
982**Atomic service API**: This API can be used in atomic services since API version 14.
983
984**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
985
986**Parameters**
987
988| Name  | Type                                                                  | Mandatory| Description                     |
989| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
990| srcFileUris | Array&lt;string&gt; | Yes| [URIs](../../file-management/user-file-uri-intro.md#media-file-uri) of the images or videos to be granted with the permission.<br>**NOTE**: Only image and video URIs are supported.|
991
992**Return value**
993
994| Type                                   | Description             |
995| --------------------------------------- | ----------------- |
996| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs granted with the save permission.|
997
998**Error codes**
999
1000For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1001
1002| ID| Error Message|
1003| -------- | ---------------------------------------- |
1004| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1005| 14000011 |  Internal system error |
1006
1007**Example**
1008
1009For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1010
1011```ts
1012import { dataSharePredicates } from '@kit.ArkData';
1013
1014async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
1015  console.info('requestPhotoUrisReadPermissionDemo.');
1016
1017  try {
1018    let phAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1019    // Obtain the URIs of the images or videos to be granted with the permission.
1020    let srcFileUris: Array<string> = [
1021      'file://fileUriDemo1' // The URI here is an example only.
1022    ];
1023    let desFileUris: Array<string> = await phAccessHelper.requestPhotoUrisReadPermission(srcFileUris);
1024    console.info('requestPhotoUrisReadPermission success, data is ' + desFileUris);
1025  } catch (err) {
1026    console.error('requestPhotoUrisReadPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1027  }
1028}
1029```
1030
1031## getSupportedPhotoFormats<sup>18+</sup>
1032
1033getSupportedPhotoFormats(photoType: PhotoType): Promise&lt;Array&lt;string&gt;&gt;
1034
1035Obtains the list of image or video file name extensions supported by the media library.
1036
1037**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1038
1039**Parameters**
1040
1041| Name  | Type                  | Mandatory| Description     |
1042|-----------|-------------------------|-----------|-----------------|
1043| photoType | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype) | Yes  | Type of the file.|
1044
1045**Return value**
1046
1047| Type                                    | Description             |
1048|------------------------------------------|-------------------------|
1049| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return an array of the supported image or video file name extensions.|
1050
1051**Error codes**
1052
1053For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1054
1055| ID| Error Message|
1056| -------- | ---------------------------------------- |
1057| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1058| 14000011 | Internal system error. It is recommended to retry and check the logs. |
1059
1060**Example**
1061
1062For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1063
1064```ts
1065async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, photoTypeNumber: number){
1066  console.info('getSupportedPhotoFormatsDemo.');
1067
1068  try {
1069    let outputText: string;
1070    if (photoTypeNumber !== photoAccessHelper.PhotoType.IMAGE && photoTypeNumber !== photoAccessHelper.PhotoType.VIDEO) {
1071      outputText = 'Does not support querying formats other than images or videos';
1072      return;
1073    }
1074    outputText = 'The supported types are:\n';
1075    let imageFormat  = await phAccessHelper.getSupportedPhotoFormats(photoAccessHelper.PhotoType.IMAGE);
1076    let result = "";
1077    for (let i = 0; i < imageFormat.length; i++) {
1078      result += imageFormat[i];
1079      if (i !== imageFormat.length - 1) {
1080        result += ', ';
1081      }
1082    }
1083    outputText += result;
1084    console.info('getSupportedPhotoFormats success, data is ' + outputText);
1085  } catch (error) {
1086    console.error('getSupportedPhotoFormats failed, errCode is', error);
1087  }
1088}
1089```
1090
1091## on('photoChange')<sup>20+</sup>
1092
1093on(type: 'photoChange', callback: Callback&lt;PhotoAssetChangeInfos&gt;): void
1094
1095Registers a listener for the **'photoChange'** event to monitor media asset changes. This API uses a callback to return the result, and it accepts multiple callbacks.
1096
1097**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1098
1099**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1100
1101**Parameters**
1102
1103| Name  | Type                  | Mandatory| Description     |
1104|-----------|-------------------------|-----------|-----------------|
1105| type | string | Yes  | Event type. The value is fixed at **'photoChange'**. After the registration is complete, any change to the media assets is returned through the callback.|
1106| callback  | Callback&lt;[PhotoAssetChangeInfos](arkts-apis-photoAccessHelper-i.md#photoassetchangeinfos20)&gt; | Yes  | Callback used to return the media asset information after change, which is [PhotoAssetChangeInfos](arkts-apis-photoAccessHelper-i.md#photoassetchangeinfos20).<br>**NOTE**: You can register multiple listeners using this API, and you can call [off('photoChange')](#offphotochange20) to unregister all listeners or a specific one.|
1107
1108**Error codes**
1109
1110For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Media Library Error Codes](errcode-medialibrary.md).
1111
1112| ID| Error Message|
1113| -------- | ---------------------------------------- |
1114| 201 | Permission denied. |
1115| 23800151 | The scenario parameter verification fails.<br>Possible causes: 1. The type is not fixed at 'photoChange'; 2. The same callback is registered repeatedly. |
1116| 23800301 | Internal system error. You are advised to retry and check the logs.<br>Possible causes: 1. The database is corrupted. 2. The file system is abnormal. 3. The IPC request timed out. |
1117
1118**Example**
1119
1120For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1121
1122```ts
1123import { dataSharePredicates } from '@kit.ArkData'
1124
1125let onCallback1 = (changeData: photoAccessHelper.PhotoAssetChangeInfos) => {
1126    console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1127  // file had changed, do something.
1128}
1129let onCallback2 = (changeData: photoAccessHelper.PhotoAssetChangeInfos) => {
1130    console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1131  // file had changed, do something.
1132}
1133
1134async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context){
1135  console.info('onPhotoChangeDemo.');
1136
1137  try {
1138    // Register onCallback1.
1139    phAccessHelper.on('photoChange', onCallback1);
1140    // Register onCallback2.
1141    phAccessHelper.on('photoChange', onCallback2);
1142  } catch (error) {
1143    console.error('onPhotoChangeDemo failed, errCode is', error);
1144  }
1145}
1146```
1147
1148## off('photoChange')<sup>20+</sup>
1149
1150off(type: 'photoChange', callback?: Callback&lt;PhotoAssetChangeInfos&gt;): void
1151
1152Unregisters the listener for the **'photoChange'** event to stop monitoring media asset changes. If multiple listeners are registered, you can unregister a specific listener by specifying **callback**. Alternatively, you can unregister all of them without specifying **callback**.
1153
1154**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1155
1156**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1157
1158**Parameters**
1159
1160| Name  | Type                  | Mandatory| Description     |
1161|-----------|-------------------------|-----------|-----------------|
1162| type | string | Yes  | Event type. The value is fixed at **'photoChange'**. After the unregistration is complete, any change to the media assets is no longer returned through the callback.|
1163| callback | Callback&lt;[PhotoAssetChangeInfos](arkts-apis-photoAccessHelper-i.md#photoassetchangeinfos20)&gt; | No  | Exact callback you previously registered with [on('photoChange')](#onphotochange20). If this parameter is left unspecified, all listeners for the **'photoChange'** event are unregistered.<br>**NOTE**: Once a specific callback is unregistered, it will not be invoked when a media asset changes.|
1164
1165**Error codes**
1166
1167For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Media Library Error Codes](errcode-medialibrary.md).
1168
1169| ID| Error Message|
1170| -------- | ---------------------------------------- |
1171| 201 | Permission denied. |
1172| 23800151 | The scenario parameter verification fails.<br>Possible causes: 1. The type is not fixed at 'photoChange'; 2. The same callback is unregistered repeatedly. |
1173| 23800301 | Internal system error. You are advised to retry and check the logs.<br>Possible causes: 1. The database is corrupted. 2. The file system is abnormal. 3. The IPC request timed out. |
1174
1175**Example**
1176
1177For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1178
1179```ts
1180import { dataSharePredicates } from '@kit.ArkData'
1181
1182let onCallback1 = (changeData: photoAccessHelper.PhotoAssetChangeInfos) => {
1183    console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1184  // file had changed, do something.
1185}
1186let onCallback2 = (changeData: photoAccessHelper.PhotoAssetChangeInfos) => {
1187    console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1188  // file had changed, do something.
1189}
1190
1191async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context){
1192  console.info('offPhotoChangeDemo.');
1193
1194  try {
1195    // Register onCallback1.
1196    phAccessHelper.on('photoChange', onCallback1);
1197    // Register onCallback2.
1198    phAccessHelper.on('photoChange', onCallback2);
1199
1200    // Unregister the listening of onCallback1.
1201    phAccessHelper.off('photoChange', onCallback1);
1202  } catch (error) {
1203    console.error('offPhotoChangeDemo failed, errCode is', error);
1204  }
1205}
1206```
1207
1208## on('photoAlbumChange')<sup>20+</sup>
1209
1210on(type: 'photoAlbumChange', callback: Callback&lt;AlbumChangeInfos&gt;): void
1211
1212Registers a listener for the **'photoAlbumChange'** event to monitor album changes. This API uses a callback to return the result, and it accepts multiple callbacks.
1213
1214**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1215
1216**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1217
1218**Parameters**
1219
1220| Name  | Type                  | Mandatory| Description     |
1221|-----------|-------------------------|-----------|-----------------|
1222| type | string | Yes  | Event type. The value is fixed at **'photoAlbumChange'**. After the registration is complete, any change to the albums is returned through the callback.|
1223| callback  | Callback&lt;[AlbumChangeInfos](arkts-apis-photoAccessHelper-i.md#albumchangeinfos20)&gt; | Yes  | Callback used to return the album information after change, which is [AlbumChangeInfos](arkts-apis-photoAccessHelper-i.md#albumchangeinfos20).<br>**NOTE**: You can register multiple listeners using this API, and you can call [off('photoAlbumChange')](#offphotoalbumchange20) to unregister all listeners or a specific one.|
1224
1225**Error codes**
1226
1227For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Media Library Error Codes](errcode-medialibrary.md).
1228
1229| ID| Error Message|
1230| -------- | ---------------------------------------- |
1231| 201 | Permission denied. |
1232| 23800151 | The scenario parameter verification fails.<br>Possible causes: 1. The type is not fixed at 'photoAlbumChange'; 2. The same callback is registered repeatedly. |
1233| 23800301 | Internal system error. You are advised to retry and check the logs.<br>Possible causes: 1. The database is corrupted. 2. The file system is abnormal. 3. The IPC request timed out. |
1234
1235**Example**
1236
1237For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1238
1239```ts
1240import { dataSharePredicates } from '@kit.ArkData'
1241
1242let onCallback1 = (changeData: photoAccessHelper.AlbumChangeInfos) => {
1243    console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1244  // file had changed, do something.
1245}
1246let onCallback2 = (changeData: photoAccessHelper.AlbumChangeInfos) => {
1247    console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1248  // file had changed, do something.
1249}
1250
1251async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context){
1252  console.info('onPhotoAlbumChangeDemo.');
1253
1254  try {
1255    // Register onCallback1.
1256    phAccessHelper.on('photoAlbumChange', onCallback1);
1257    // Register onCallback2.
1258    phAccessHelper.on('photoAlbumChange', onCallback2);
1259  } catch (error) {
1260    console.error('onPhotoAlbumChangeDemo failed, errCode is', error);
1261  }
1262}
1263```
1264
1265## off('photoAlbumChange')<sup>20+</sup>
1266
1267off(type: 'photoAlbumChange', callback?: Callback&lt;AlbumChangeInfos&gt;): void
1268
1269Unregisters a listener for the **'photoAlbumChange'** event to stop monitoring album changes. If multiple listeners are registered, you can unregister a specific listener by specifying **callback**. Alternatively, you can unregister all of them without specifying **callback**.
1270
1271**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1272
1273**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1274
1275**Parameters**
1276
1277| Name  | Type                  | Mandatory| Description     |
1278|-----------|-------------------------|-----------|-----------------|
1279| type | string | Yes  | Event type. The value is fixed at **'photoAlbumChange'**. After the unregistration is complete, any change to the albums is no longer returned through the callback.|
1280| callback | Callback&lt;[AlbumChangeInfos](arkts-apis-photoAccessHelper-i.md#albumchangeinfos20)&gt; | No  | Exact callback you previously registered with [on('photoAlbumChange')](#onphotoalbumchange20). If this parameter is left unspecified, all listeners for the **'photoAlbumChange'** event are unregistered.<br>**NOTE**: Once a specific callback is unregistered, it will not be invoked when an album changes.|
1281
1282**Error codes**
1283
1284For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Media Library Error Codes](errcode-medialibrary.md).
1285
1286| ID| Error Message|
1287| -------- | ---------------------------------------- |
1288| 201 | Permission denied. |
1289| 23800151 | The scenario parameter verification fails.<br>Possible causes: 1. The type is not fixed at 'photoAlbumChange'; 2. The same callback is unregistered repeatedly. |
1290| 23800301 | Internal system error. You are advised to retry and check the logs.<br>Possible causes: 1. The database is corrupted. 2. The file system is abnormal. 3. The IPC request timed out. |
1291
1292**Example**
1293
1294For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1295
1296```ts
1297import { dataSharePredicates } from '@kit.ArkData'
1298
1299let onCallback1 = (changeData: photoAccessHelper.AlbumChangeInfos) => {
1300    console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1301  // file had changed, do something.
1302}
1303let onCallback2 = (changeData: photoAccessHelper.AlbumChangeInfos) => {
1304    console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1305  // file had changed, do something.
1306}
1307
1308async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context){
1309  console.info('onPhotoAlbumChangeDemo.');
1310
1311  try {
1312    // Register onCallback1.
1313    phAccessHelper.on('photoAlbumChange', onCallback1);
1314    // Register onCallback2.
1315    phAccessHelper.on('photoAlbumChange', onCallback2);
1316
1317    // Unregister the listening of onCallback1.
1318    phAccessHelper.off('photoAlbumChange', onCallback1);
1319  } catch (error) {
1320    console.error('onPhotoAlbumChangeDemo failed, errCode is', error);
1321  }
1322}
1323```
1324
1325## getPhotoPickerComponentDefaultAlbumName<sup>20+</sup>
1326
1327getPhotoPickerComponentDefaultAlbumName(): Promise&lt;string&gt;
1328
1329Obtains the name of the album that the **PhotoPickerComponent** shows by default. The name string is localized to match the current system language. This API uses a promise to return the result.
1330
1331**Atomic service API**: This API can be used in atomic services since API version 20.
1332
1333**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1334
1335**Return value**
1336
1337| Type                                   | Description             |
1338| --------------------------------------- | ----------------- |
1339| Promise&lt;string&gt;| Promise used to return the name of the default album.|
1340
1341**Error codes**
1342
1343For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1344
1345| ID| Error Message|
1346| -------- | ---------------------------------------- |
1347| 23800301   | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. The IPC request timed out. 2. system running error.         |
1348
1349**Example**
1350
1351```ts
1352import { BusinessError } from '@kit.BasicServicesKit';
1353import {photoAccessHelper} from '@kit.MediaLibraryKit';
1354
1355async function example(context: Context) {
1356  console.info('getPhotoPickerComponentDefaultAlbumNameDemo');
1357  let phAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1358
1359  phAccessHelper.getPhotoPickerComponentDefaultAlbumName().then((defaultAlbumName) => {
1360    console.info('getPhotoPickerComponentDefaultAlbumName success, defaultAlbumName is ' + defaultAlbumName);
1361  }).catch((err: BusinessError) => {
1362    console.error(`getPhotoPickerComponentDefaultAlbumName failed with error: ${err.code}, ${err.message}`);
1363  });
1364}
1365```
1366
1367## createDeleteRequest<sup>(deprecated)</sup>
1368
1369createDeleteRequest(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
1370
1371Creates a dialog box for deleting media files. This API uses an asynchronous callback to return the result. The deleted media files are moved to the trash.
1372
1373> **NOTE**
1374>
1375> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [MediaAssetChangeRequest.deleteAssets](arkts-apis-photoAccessHelper-MediaAssetChangeRequest.md#deleteassets11-1) instead.
1376
1377**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1378
1379**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1380
1381**Parameters**
1382
1383| Name  | Type                     | Mandatory| Description      |
1384| -------- | ------------------------- | ---- | ---------- |
1385| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
1386| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1387
1388**Error codes**
1389
1390For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1391
1392If error code 13900012 is returned, follow the instructions provided in [Before You Start](../../media/medialibrary/photoAccessHelper-preparation.md).
1393
1394| ID| Error Message|
1395| -------- | ---------------------------------------- |
1396| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1397| 13900012     | Permission denied.         |
1398| 13900020     | Invalid argument.         |
1399| 14000011       | System inner fail.         |
1400
1401**Example**
1402
1403For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1404
1405```ts
1406import { dataSharePredicates } from '@kit.ArkData';
1407
1408async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
1409  console.info('createDeleteRequestDemo');
1410  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1411  let fetchOptions: photoAccessHelper.FetchOptions = {
1412    fetchColumns: [],
1413    predicates: predicates
1414  };
1415  try {
1416    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1417    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1418    if (asset === undefined) {
1419      console.error('asset not exist');
1420      return;
1421    }
1422    phAccessHelper.createDeleteRequest([asset.uri], (err) => {
1423      if (err === undefined) {
1424        console.info('createDeleteRequest successfully');
1425      } else {
1426        console.error(`createDeleteRequest failed with error: ${err.code}, ${err.message}`);
1427      }
1428    });
1429  } catch (err) {
1430    console.error(`fetch failed, error: ${err.code}, ${err.message}`);
1431  }
1432}
1433```
1434
1435## createDeleteRequest<sup>(deprecated)</sup>
1436
1437createDeleteRequest(uriList: Array&lt;string&gt;): Promise&lt;void&gt;
1438
1439Creates a dialog box for deleting media files. This API uses a promise to return the result. The deleted media files are moved to the trash.
1440
1441> **NOTE**
1442>
1443> This API is supported since API version 10 and deprecated since API version 11. You are advised to use [MediaAssetChangeRequest.deleteAssets](arkts-apis-photoAccessHelper-MediaAssetChangeRequest.md#deleteassets11-1) instead.
1444
1445**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1446
1447**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1448
1449**Parameters**
1450
1451| Name  | Type                     | Mandatory| Description      |
1452| -------- | ------------------------- | ---- | ---------- |
1453| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
1454
1455**Return value**
1456
1457| Type                                   | Description             |
1458| --------------------------------------- | ----------------- |
1459| Promise&lt;void&gt;| Promise that returns no value.|
1460
1461**Error codes**
1462
1463For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1464
1465If error code 13900012 is returned, follow the instructions provided in [Before You Start](../../media/medialibrary/photoAccessHelper-preparation.md).
1466
1467| ID| Error Message|
1468| -------- | ---------------------------------------- |
1469| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1470| 13900012     | Permission denied.         |
1471| 13900020     | Invalid argument.         |
1472| 14000011       | System inner fail.         |
1473
1474**Example**
1475
1476For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
1477
1478```ts
1479import { dataSharePredicates } from '@kit.ArkData';
1480
1481async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
1482  console.info('createDeleteRequestDemo');
1483  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1484  let fetchOptions: photoAccessHelper.FetchOptions = {
1485    fetchColumns: [],
1486    predicates: predicates
1487  };
1488  try {
1489    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1490    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1491    if (asset === undefined) {
1492      console.error('asset not exist');
1493      return;
1494    }
1495    await phAccessHelper.createDeleteRequest([asset.uri]);
1496    console.info('createDeleteRequest successfully');
1497  } catch (err) {
1498    console.error(`createDeleteRequest failed with error: ${err.code}, ${err.message}`);
1499  }
1500}
1501```
1502
1503## getRecentPhotoInfo<sup>20+</sup>
1504
1505getRecentPhotoInfo(options?: RecentPhotoOptions): Promise\<RecentPhotoInfo>
1506
1507Obtains the information about the recent image or video when the application uses the **RecentPhotoComponent** to view recent images or videos. This API uses a promise to return the result.
1508
1509**Atomic service API**: This API can be used in atomic services since API version 20.
1510
1511**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1512
1513**Parameters**
1514
1515| Name | Type   | Mandatory| Description                      |
1516| ------- | ------- | ---- | -------------------------- |
1517| options | [RecentPhotoOptions](arkts-apis-photoAccessHelper-class.md#RecentPhotoOptions20) | No  | Options for retrieving the recent image or video. If this parameter is not provided, the API finds the recent image or video based on the timestamp.<br>If this parameter is specified, it must match the **options** configuration in the **RecentPhotoComponent**. Otherwise, there may be discrepancies where the API finds a recent image or video but the component does not.|
1518
1519**Return value**
1520
1521| Type                                   | Description             |
1522| --------------------------------------- | ----------------- |
1523| Promise\<[RecentPhotoInfo](arkts-apis-photoAccessHelper-class.md#RecentPhotoInfo20)>| Promise used to return the information about the recent image or video.|
1524
1525**Example**
1526
1527```ts
1528import { BusinessError } from '@kit.BasicServicesKit';
1529import { photoAccessHelper, PhotoSource, RecentPhotoOptions} from '@kit.MediaLibraryKit';
1530
1531async function example(context: Context) {
1532  console.info('getRecentPhotoInfoDemo');
1533  let phAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1534  let recentPhotoOptions: RecentPhotoOptions = {
1535    period: 60 * 60,
1536    MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE,
1537    photoSource: PhotoSource.ALL
1538  }
1539
1540  phAccessHelper.getRecentPhotoInfo(recentPhotoOptions).then((recentPhotoInfo) => {
1541    console.info('getRecentPhotoInfo success, recentPhotoInfo is ' + JSON.stringify(recentPhotoInfo));
1542  }).catch((err: BusinessError) => {
1543    console.error(`getRecentPhotoInfo failed with error: ${err.code}, ${err.message}`);
1544  });
1545}
1546```
1547