• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.photoAccessHelper (Album Management)
2
3The **photoAccessHelper** module provides APIs for album management, including creating an album and accessing and modifying media data in an album.
4
5> **NOTE**
6>
7> 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.
8
9## Modules to Import
10
11```ts
12import photoAccessHelper from '@ohos.file.photoAccessHelper';
13```
14
15## photoAccessHelper.getPhotoAccessHelper
16
17getPhotoAccessHelper(context: Context): PhotoAccessHelper
18
19Obtains a **PhotoAccessHelper** instance for accessing and modifying media files in the album.
20
21**Model restriction**: This API can be used only in the stage model.
22
23**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
24
25**Parameters**
26
27| Name | Type   | Mandatory| Description                      |
28| ------- | ------- | ---- | -------------------------- |
29| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
30
31**Return value**
32
33| Type                           | Description   |
34| ----------------------------- | :---- |
35| [PhotoAccessHelper](#photoaccesshelper) | **PhotoAccessHelper** instance obtained.|
36
37**Error codes**
38
39For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md).
40
41| ID| Error Message|
42| -------- | ---------------------------------------- |
43| 401   | if parameter is invalid.         |
44
45**Example**
46
47```ts
48// The phAccessHelper instance obtained is a global object. It is used by default in subsequent operations. If the code snippet is not added, an error will be reported indicating that phAccessHelper is not defined.
49let context = getContext(this);
50let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
51```
52
53## PhotoAccessHelper
54
55### getAssets
56
57getAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<PhotoAsset>>): void
58
59Obtains image and video assets. This API uses an asynchronous callback to return the result.
60
61**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
62
63**Required permissions**: ohos.permission.READ_IMAGEVIDEO
64
65**Parameters**
66
67| Name  | Type                    | Mandatory| Description                     |
68| -------- | ------------------------ | ---- | ------------------------- |
69| options  | [FetchOptions](#fetchoptions)        | Yes  | Options for fetching the image and video assets.             |
70| callback |  AsyncCallback<[FetchResult](#fetchresult)<[PhotoAsset](#photoasset)>> | Yes  | Callback invoked to return the image and video assets obtained.|
71
72**Error codes**
73
74For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
75
76| ID| Error Message|
77| -------- | ---------------------------------------- |
78| 401      |  if parameter is invalid.         |
79| 13900012     | Permission denied.         |
80| 13900020     | Invalid argument.         |
81| 14000011       | System inner fail.         |
82
83**Example**
84
85```ts
86import dataSharePredicates from '@ohos.data.dataSharePredicates';
87
88async function example() {
89  console.info('getAssets');
90  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
91  let fetchOptions: photoAccessHelper.FetchOptions = {
92    fetchColumns: [],
93    predicates: predicates
94  };
95
96  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
97    if (fetchResult !== undefined) {
98      console.info('fetchResult success');
99      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
100      if (photoAsset !== undefined) {
101        console.info('photoAsset.displayName : ' + photoAsset.displayName);
102      }
103    } else {
104      console.error('fetchResult fail' + err);
105    }
106  });
107}
108```
109
110### getAssets
111
112getAssets(options: FetchOptions): Promise<FetchResult<PhotoAsset>>
113
114Obtains image and video assets. This API uses a promise to return the result.
115
116**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
117
118**Required permissions**: ohos.permission.READ_IMAGEVIDEO
119
120**Parameters**
121
122| Name | Type               | Mandatory| Description            |
123| ------- | ------------------- | ---- | ---------------- |
124| options | [FetchOptions](#fetchoptions)   | Yes  | Options for fetching the image and video assets.    |
125
126**Return value**
127
128| Type                       | Description          |
129| --------------------------- | -------------- |
130| Promise<[FetchResult](#fetchresult)<[PhotoAsset](#photoasset)>> | Promise used to return the image and video assets obtained.|
131
132**Error codes**
133
134For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
135
136| ID| Error Message|
137| -------- | ---------------------------------------- |
138| 401      |  if parameter is invalid.         |
139| 13900012     | Permission denied.         |
140| 13900020     | Invalid argument.         |
141| 14000011       | System inner fail.         |
142
143**Example**
144
145```ts
146import dataSharePredicates from '@ohos.data.dataSharePredicates';
147
148async function example() {
149  console.info('getAssets');
150  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
151  let fetchOptions: photoAccessHelper.FetchOptions = {
152    fetchColumns: [],
153    predicates: predicates
154  };
155  try {
156    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
157    if (fetchResult !== undefined) {
158      console.info('fetchResult success');
159      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
160      if (photoAsset !== undefined) {
161        console.info('photoAsset.displayName :' + photoAsset.displayName);
162      }
163    }
164  } catch (err) {
165    console.error('getAssets failed, message = ', err);
166  }
167}
168```
169
170### createAsset
171
172createAsset(displayName: string, callback: AsyncCallback&lt;PhotoAsset&gt;): void
173
174Creates an image or video asset with the specified file name. This API uses an asynchronous callback to return the result.
175
176The file name must comply with the following specifications:
177- The file name must contain a valid file name and an image or video file name extension.
178- The file name cannot exceed 255 characters.
179- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
180
181**System API**: This is a system API.
182
183**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
184
185**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
186
187**Parameters**
188
189| Name  | Type                    | Mandatory| Description                     |
190| -------- | ------------------------ | ---- | ------------------------- |
191| displayName  | string        | Yes  | File name of the image or video to create.             |
192| callback |  AsyncCallback&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Callback invoked to return the image or video created.|
193
194**Error codes**
195
196For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
197
198| ID| Error Message|
199| -------- | ---------------------------------------- |
200| 202   |  Called by non-system application.         |
201| 401      |  if parameter is invalid.         |
202| 13900012     | Permission denied.         |
203| 13900020     | Invalid argument.         |
204| 14000001      | Invalid display name.         |
205| 14000011       | System inner fail.         |
206
207**Example**
208
209```ts
210async function example() {
211  console.info('createAssetDemo');
212  let testFileName: string = 'testFile' + Date.now() + '.jpg';
213  phAccessHelper.createAsset(testFileName, (err, photoAsset) => {
214    if (photoAsset !== undefined) {
215      console.info('createAsset file displayName' + photoAsset.displayName);
216      console.info('createAsset successfully');
217    } else {
218      console.error('createAsset failed, message = ', err);
219    }
220  });
221}
222```
223
224### createAsset
225
226createAsset(displayName: string): Promise&lt;PhotoAsset&gt;
227
228Creates an image or video asset with the specified file name. This API uses a promise to return the result.
229
230The file name must comply with the following specifications:
231- The file name must contain a valid file name and an image or video file name extension.
232- The file name cannot exceed 255 characters.
233- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
234
235**System API**: This is a system API.
236
237**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
238
239**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
240
241**Parameters**
242
243| Name  | Type                    | Mandatory| Description                     |
244| -------- | ------------------------ | ---- | ------------------------- |
245| displayName  | string        | Yes  | File name of the image or video to create.             |
246
247**Return value**
248
249| Type                       | Description          |
250| --------------------------- | -------------- |
251| Promise&lt;[PhotoAsset](#photoasset)&gt; | Promise used to return the created image and video asset.|
252
253**Error codes**
254
255For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
256
257| ID| Error Message|
258| -------- | ---------------------------------------- |
259| 202   |  Called by non-system application.         |
260| 401      |  if parameter is invalid.         |
261| 13900012     | Permission denied.         |
262| 13900020     | Invalid argument.         |
263| 14000001      | Invalid display name.         |
264| 14000011       | System inner fail.         |
265
266**Example**
267
268```ts
269async function example() {
270  console.info('createAssetDemo');
271  try {
272    let testFileName: string = 'testFile' + Date.now() + '.jpg';
273    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
274    console.info('createAsset file displayName' + photoAsset.displayName);
275    console.info('createAsset successfully');
276  } catch (err) {
277    console.error('createAsset failed, message = ', err);
278  }
279}
280```
281
282### createAsset
283
284createAsset(displayName: string, options: PhotoCreateOptions, callback: AsyncCallback&lt;PhotoAsset&gt;): void
285
286Creates an image or video asset with the specified file name and options. This API uses an asynchronous callback to return the result.
287
288The file name must comply with the following specifications:
289- The file name must contain a valid file name and an image or video file name extension.
290- The file name cannot exceed 255 characters.
291- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
292
293**System API**: This is a system API.
294
295**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
296
297**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
298
299**Parameters**
300
301| Name  | Type                    | Mandatory| Description                     |
302| -------- | ------------------------ | ---- | ------------------------- |
303| displayName  | string        | Yes  | File name of the image or video to create.             |
304| options  | [PhotoCreateOptions](#photocreateoptions)        | Yes  | Options for creating an image or video asset.             |
305| callback |  AsyncCallback&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Callback invoked to return the image or video created.|
306
307**Error codes**
308
309For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
310
311| ID| Error Message|
312| -------- | ---------------------------------------- |
313| 202   |  Called by non-system application.         |
314| 401      |  if parameter is invalid.         |
315| 13900012     | Permission denied.         |
316| 13900020     | Invalid argument.         |
317| 14000001      | Invalid display name.         |
318| 14000011       | System inner fail.         |
319
320**Example**
321
322```ts
323async function example() {
324  console.info('createAssetDemo');
325  let testFileName: string = 'testFile' + Date.now() + '.jpg';
326  let createOption: photoAccessHelper.PhotoCreateOptions = {
327    subtype: photoAccessHelper.PhotoSubtype.DEFAULT
328  }
329  phAccessHelper.createAsset(testFileName, createOption, (err, photoAsset) => {
330    if (photoAsset !== undefined) {
331      console.info('createAsset file displayName' + photoAsset.displayName);
332      console.info('createAsset successfully');
333    } else {
334      console.error('createAsset failed, message = ', err);
335    }
336  });
337}
338```
339
340### createAsset
341
342createAsset(displayName: string, options: PhotoCreateOptions): Promise&lt;PhotoAsset&gt;
343
344Creates an image or video asset with the specified file name and options. This API uses a promise to return the result.
345
346The file name must comply with the following specifications:
347- The file name must contain a valid file name and an image or video file name extension.
348- The file name cannot exceed 255 characters.
349- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
350
351**System API**: This is a system API.
352
353**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
354
355**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
356
357**Parameters**
358
359| Name  | Type                    | Mandatory| Description                     |
360| -------- | ------------------------ | ---- | ------------------------- |
361| displayName  | string        | Yes  | File name of the image or video to create.             |
362| options  |  [PhotoCreateOptions](#photocreateoptions)       | Yes  | Options for creating an image or video asset.             |
363
364**Return value**
365
366| Type                       | Description          |
367| --------------------------- | -------------- |
368| Promise&lt;[PhotoAsset](#photoasset)&gt; | Promise used to return the created image and video asset.|
369
370**Error codes**
371
372For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
373
374| ID| Error Message|
375| -------- | ---------------------------------------- |
376| 202   |  Called by non-system application.         |
377| 401      |  if parameter is invalid.         |
378| 13900012     | Permission denied.         |
379| 13900020     | Invalid argument.         |
380| 14000001      | Invalid display name.         |
381| 14000011       | System inner fail.         |
382
383**Example**
384
385```ts
386async function example() {
387  console.info('createAssetDemo');
388  try {
389    let testFileName:string = 'testFile' + Date.now() + '.jpg';
390    let createOption: photoAccessHelper.PhotoCreateOptions = {
391      subtype: photoAccessHelper.PhotoSubtype.DEFAULT
392    }
393    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName, createOption);
394    console.info('createAsset file displayName' + photoAsset.displayName);
395    console.info('createAsset successfully');
396  } catch (err) {
397    console.error('createAsset failed, message = ', err);
398  }
399}
400```
401
402### createAsset
403
404createAsset(photoType: PhotoType, extension: string, options: CreateOptions, callback: AsyncCallback&lt;string&gt;): void
405
406Creates 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.
407
408If the application does not have the **ohos.permission.WRITE_IMAGEVIDEO** permission, you can use a security component to create a media asset. For details, see [Creating a Media Asset Using a Security Component](../../file-management/photoAccessHelper-resource-guidelines.md#creating-a-media-asset-using-a-security-component).
409
410**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
411
412**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
413
414**Parameters**
415
416| Name  | Type                    | Mandatory| Description                     |
417| -------- | ------------------------ | ---- | ------------------------- |
418| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
419| extension  | string        | Yes  | File name extension, for example, **jpg**.             |
420| options  | [CreateOptions](#createoptions)        | Yes  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
421| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback invoked to return the URI of the created image or video.|
422
423**Error codes**
424
425For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
426
427| ID| Error Message|
428| -------- | ---------------------------------------- |
429| 401      |  if parameter is invalid.         |
430| 13900012     | Permission denied.         |
431| 13900020     | Invalid argument.         |
432| 14000011       | System inner fail.         |
433
434**Example**
435
436```ts
437async function example() {
438  console.info('createAssetDemo');
439  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
440  let extension:string = 'jpg';
441  let options: photoAccessHelper.CreateOptions = {
442    title: 'testPhoto'
443  }
444  phAccessHelper.createAsset(photoType, extension, options, (err, uri) => {
445    if (uri !== undefined) {
446      console.info('createAsset uri' + uri);
447      console.info('createAsset successfully');
448    } else {
449      console.error('createAsset failed, message = ', err);
450    }
451  });
452}
453```
454
455### createAsset
456
457createAsset(photoType: PhotoType, extension: string, callback: AsyncCallback&lt;string&gt;): void
458
459Creates an image or video asset with the specified file type and file name extension. This API uses an asynchronous callback to return the result.
460
461If the application does not have the **ohos.permission.WRITE_IMAGEVIDEO** permission, you can use a security component to create a media asset. For details, see [Creating a Media Asset Using a Security Component](../../file-management/photoAccessHelper-resource-guidelines.md#creating-a-media-asset-using-a-security-component).
462
463**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
464
465**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
466
467**Parameters**
468
469| Name  | Type                    | Mandatory| Description                     |
470| -------- | ------------------------ | ---- | ------------------------- |
471| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
472| extension  | string        | Yes  | File name extension, for example, **jpg**.             |
473| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback invoked to return the URI of the created image or video.|
474
475**Error codes**
476
477For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
478
479| ID| Error Message|
480| -------- | ---------------------------------------- |
481| 401      |  if parameter is invalid.         |
482| 13900012     | Permission denied.         |
483| 13900020     | Invalid argument.         |
484| 14000011       | System inner fail.         |
485
486**Example**
487
488```ts
489async function example() {
490  console.info('createAssetDemo');
491  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
492  let extension: string = 'jpg';
493  phAccessHelper.createAsset(photoType, extension, (err, uri) => {
494    if (uri !== undefined) {
495      console.info('createAsset uri' + uri);
496      console.info('createAsset successfully');
497    } else {
498      console.error('createAsset failed, message = ', err);
499    }
500  });
501}
502```
503
504### createAsset
505
506createAsset(photoType: PhotoType, extension: string, options?: CreateOptions): Promise&lt;string&gt;
507
508Creates an image or video asset with the specified file type, file name extension, and options. This API uses a promise to return the result.
509
510If the application does not have the **ohos.permission.WRITE_IMAGEVIDEO** permission, you can use a security component to create a media asset. For details, see [Creating a Media Asset Using a Security Component](../../file-management/photoAccessHelper-resource-guidelines.md#creating-a-media-asset-using-a-security-component).
511
512**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
513
514**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
515
516**Parameters**
517
518| Name  | Type                    | Mandatory| Description                     |
519| -------- | ------------------------ | ---- | ------------------------- |
520| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
521| extension  | string        | Yes  | File name extension, for example, **jpg**.             |
522| options  | [CreateOptions](#createoptions)        | No  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
523
524**Return value**
525
526| Type                       | Description          |
527| --------------------------- | -------------- |
528| Promise&lt;string&gt; | Promise used to return the URI of the created image or video asset.|
529
530**Error codes**
531
532For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
533
534| ID| Error Message|
535| -------- | ---------------------------------------- |
536| 401      |  if parameter is invalid.         |
537| 13900012     | Permission denied.         |
538| 13900020     | Invalid argument.         |
539| 14000011       | System inner fail.         |
540
541**Example**
542
543```ts
544async function example() {
545  console.info('createAssetDemo');
546  try {
547    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
548    let extension: string = 'jpg';
549    let options: photoAccessHelper.CreateOptions = {
550      title: 'testPhoto'
551    }
552    let uri: string = await phAccessHelper.createAsset(photoType, extension, options);
553    console.info('createAsset uri' + uri);
554    console.info('createAsset successfully');
555  } catch (err) {
556    console.error('createAsset failed, message = ', err);
557  }
558}
559```
560
561### createAlbum<sup>(deprecated)</sup>
562
563createAlbum(name: string, callback: AsyncCallback&lt;Album&gt;): void
564
565Creates an album. This API uses an asynchronous callback to return the result.
566
567The album name must meet the following requirements:
568- The album name is a string of 1 to 255 characters.
569- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
570- The album name is case-insensitive.
571- Duplicate album names are not allowed.
572
573> **NOTE**
574>
575> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11) instead.
576
577**System API**: This is a system API.
578
579**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
580
581**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
582
583**Parameters**
584
585| Name  | Type                    | Mandatory| Description                     |
586| -------- | ------------------------ | ---- | ------------------------- |
587| name  | string         | Yes  | Name of the album to create.             |
588| callback |  AsyncCallback&lt;[Album](#album)&gt; | Yes  | Callback invoked to return the created album instance.|
589
590**Error codes**
591
592For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
593
594| ID| Error Message|
595| -------- | ---------------------------------------- |
596| 202   |  Called by non-system application.         |
597| 401      |  if parameter is invalid.         |
598| 13900012     | Permission denied.         |
599| 13900015       |  File exists.         |
600| 13900020     | Invalid argument.         |
601| 14000011       | System inner fail.         |
602
603**Example**
604
605```ts
606async function example() {
607  console.info('createAlbumDemo');
608  let albumName: string = 'newAlbumName' + new Date().getTime();
609  phAccessHelper.createAlbum(albumName, (err, album) => {
610    if (err) {
611      console.error('createAlbumCallback failed with err: ' + err);
612      return;
613    }
614    console.info('createAlbumCallback successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
615  });
616}
617```
618
619### createAlbum<sup>(deprecated)</sup>
620
621createAlbum(name: string): Promise&lt;Album&gt;
622
623Creates an album. This API uses a promise to return the result.
624
625The album name must meet the following requirements:
626- The album name is a string of 1 to 255 characters.
627- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
628- The album name is case-insensitive.
629- Duplicate album names are not allowed.
630
631> **NOTE**
632>
633> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11) instead.
634
635**System API**: This is a system API.
636
637**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
638
639**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
640
641**Parameters**
642
643| Name  | Type                    | Mandatory| Description                     |
644| -------- | ------------------------ | ---- | ------------------------- |
645| name  | string         | Yes  | Name of the album to create.             |
646
647**Return value**
648
649| Type                       | Description          |
650| --------------------------- | -------------- |
651| Promise&lt;[Album](#album)&gt; | Promise used to return the created album instance.|
652
653**Error codes**
654
655For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
656
657| ID| Error Message|
658| -------- | ---------------------------------------- |
659| 202   |  Called by non-system application.         |
660| 401      |  if parameter is invalid.         |
661| 13900012     | Permission denied.         |
662| 13900015       |  File exists.         |
663| 13900020     | Invalid argument.         |
664| 14000011       | System inner fail.         |
665
666**Example**
667
668```ts
669import { BusinessError } from '@ohos.base';
670
671async function example() {
672  console.info('createAlbumDemo');
673  let albumName: string = 'newAlbumName' + new Date().getTime();
674  phAccessHelper.createAlbum(albumName).then((album) => {
675    console.info('createAlbumPromise successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
676  }).catch((err: BusinessError) => {
677    console.error('createAlbumPromise failed with err: ' + err);
678  });
679}
680```
681
682### deleteAlbums<sup>(deprecated)</sup>
683
684deleteAlbums(albums: Array&lt;Album&gt;, callback: AsyncCallback&lt;void&gt;): void
685
686Deletes albums. This API uses an asynchronous callback to return the result.
687
688Ensure that the albums to be deleted exist. Only user albums can be deleted.
689
690> **NOTE**
691>
692> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAlbums](#deletealbums11) instead.
693
694**System API**: This is a system API.
695
696**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
697
698**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
699
700**Parameters**
701
702| Name  | Type                    | Mandatory| Description                     |
703| -------- | ------------------------ | ---- | ------------------------- |
704| albums  | Array&lt;[Album](#album)&gt;         | Yes  | Albums to delete.             |
705| callback |  AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
706
707**Error codes**
708
709For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
710
711| ID| Error Message|
712| -------- | ---------------------------------------- |
713| 202   |  Called by non-system application.         |
714| 401      |  if parameter is invalid.         |
715| 13900012     | Permission denied.         |
716| 13900020     | Invalid argument.         |
717| 14000011       | System inner fail.         |
718
719**Example**
720
721```ts
722import dataSharePredicates from '@ohos.data.dataSharePredicates';
723
724async function example() {
725  // Delete the album named newAlbumName.
726  console.info('deleteAlbumsDemo');
727  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
728  predicates.equalTo('album_name', 'newAlbumName');
729  let fetchOptions: photoAccessHelper.FetchOptions = {
730    fetchColumns: [],
731    predicates: predicates
732  };
733  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
734  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
735  phAccessHelper.deleteAlbums([album], (err) => {
736    if (err) {
737      console.error('deletePhotoAlbumsCallback failed with err: ' + err);
738      return;
739    }
740    console.info('deletePhotoAlbumsCallback successfully');
741  });
742  fetchResult.close();
743}
744```
745
746### deleteAlbums<sup>(deprecated)</sup>
747
748deleteAlbums(albums: Array&lt;Album&gt;): Promise&lt;void&gt;
749
750Deletes albums. This API uses a promise to return the result.
751
752Ensure that the albums to be deleted exist. Only user albums can be deleted.
753
754> **NOTE**
755>
756> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAlbums](#deletealbums11) instead.
757
758**System API**: This is a system API.
759
760**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
761
762**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
763
764**Parameters**
765
766| Name  | Type                    | Mandatory| Description                     |
767| -------- | ------------------------ | ---- | ------------------------- |
768| albums  |  Array&lt;[Album](#album)&gt;          | Yes  | Albums to delete.             |
769
770**Return value**
771
772| Type                       | Description          |
773| --------------------------- | -------------- |
774| Promise&lt;void&gt; | Promise that returns no value.|
775
776**Error codes**
777
778For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
779
780| ID| Error Message|
781| -------- | ---------------------------------------- |
782| 202   |  Called by non-system application.         |
783| 401      |  if parameter is invalid.         |
784| 13900012     | Permission denied.         |
785| 13900020     | Invalid argument.         |
786| 14000011       | System inner fail.         |
787
788**Example**
789
790```ts
791import dataSharePredicates from '@ohos.data.dataSharePredicates';
792import { BusinessError } from '@ohos.base';
793
794async function example() {
795  // Delete the album named newAlbumName.
796  console.info('deleteAlbumsDemo');
797  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
798  predicates.equalTo('album_name', 'newAlbumName');
799  let fetchOptions: photoAccessHelper.FetchOptions = {
800    fetchColumns: [],
801    predicates: predicates
802  };
803  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
804  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
805  phAccessHelper.deleteAlbums([album]).then(() => {
806    console.info('deletePhotoAlbumsPromise successfully');
807    }).catch((err: BusinessError) => {
808      console.error('deletePhotoAlbumsPromise failed with err: ' + err);
809  });
810  fetchResult.close();
811}
812```
813
814### getAlbums
815
816getAlbums(type: AlbumType, subtype: AlbumSubtype, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
817
818Obtains albums based on the specified options and album type. This API uses an asynchronous callback to return the result.
819
820Before the operation, ensure that the albums to obtain exist.
821
822**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
823
824**Required permissions**: ohos.permission.READ_IMAGEVIDEO
825
826**Parameters**
827
828| Name  | Type                    | Mandatory| Description                     |
829| -------- | ------------------------ | ---- | ------------------------- |
830| type  | [AlbumType](#albumtype)         | Yes  | Type of the album to obtain.             |
831| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
832| options  | [FetchOptions](#fetchoptions)         | Yes  |  Options for fetching the albums.             |
833| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
834
835**Error codes**
836
837For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
838
839| ID| Error Message|
840| -------- | ---------------------------------------- |
841| 401      |  if parameter is invalid.         |
842| 13900012     | Permission denied.         |
843| 13900020     | Invalid argument.         |
844| 14000011       | System inner fail.         |
845
846**Example**
847
848```ts
849import dataSharePredicates from '@ohos.data.dataSharePredicates';
850
851async function example() {
852  // Obtain the album named newAlbumName.
853  console.info('getAlbumsDemo');
854  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
855  predicates.equalTo('album_name', 'newAlbumName');
856  let fetchOptions: photoAccessHelper.FetchOptions = {
857    fetchColumns: [],
858    predicates: predicates
859  };
860  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions, async (err, fetchResult) => {
861    if (err) {
862      console.error('getAlbumsCallback failed with err: ' + err);
863      return;
864    }
865    if (fetchResult === undefined) {
866      console.error('getAlbumsCallback fetchResult is undefined');
867      return;
868    }
869    let album = await fetchResult.getFirstObject();
870    console.info('getAlbumsCallback successfully, albumName: ' + album.albumName);
871    fetchResult.close();
872  });
873}
874```
875
876### getAlbums
877
878getAlbums(type: AlbumType, subtype: AlbumSubtype, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
879
880Obtains albums by type. This API uses an asynchronous callback to return the result.
881
882Before the operation, ensure that the albums to obtain exist.
883
884**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
885
886**Required permissions**: ohos.permission.READ_IMAGEVIDEO
887
888**Parameters**
889
890| Name  | Type                    | Mandatory| Description                     |
891| -------- | ------------------------ | ---- | ------------------------- |
892| type  | [AlbumType](#albumtype)         | Yes  | Type of the album to obtain.             |
893| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
894| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
895
896**Error codes**
897
898For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
899
900| ID| Error Message|
901| -------- | ---------------------------------------- |
902| 401      |  if parameter is invalid.         |
903| 13900012     | Permission denied.         |
904| 13900020     | Invalid argument.         |
905| 14000011       | System inner fail.         |
906
907**Example**
908
909```ts
910async function example() {
911  // Obtain the system album VIDEO, which is preset by default.
912  console.info('getAlbumsDemo');
913  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.VIDEO, async (err, fetchResult) => {
914    if (err) {
915      console.error('getAlbumsCallback failed with err: ' + err);
916      return;
917    }
918    if (fetchResult === undefined) {
919      console.error('getAlbumsCallback fetchResult is undefined');
920      return;
921    }
922    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
923    console.info('getAlbumsCallback successfully, albumUri: ' + album.albumUri);
924    fetchResult.close();
925  });
926}
927```
928
929### getAlbums
930
931getAlbums(type: AlbumType, subtype: AlbumSubtype, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
932
933Obtains albums based on the specified options and album type. This API uses a promise to return the result.
934
935Before the operation, ensure that the albums to obtain exist.
936
937**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
938
939**Required permissions**: ohos.permission.READ_IMAGEVIDEO
940
941**Parameters**
942
943| Name  | Type                    | Mandatory| Description                     |
944| -------- | ------------------------ | ---- | ------------------------- |
945| type  | [AlbumType](#albumtype)         | Yes  | Type of the album to obtain.             |
946| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
947| options  | [FetchOptions](#fetchoptions)         | No  |  Options for fetching the albums. If this parameter is not specified, the albums are obtained based on the album type by default.             |
948
949**Return value**
950
951| Type                       | Description          |
952| --------------------------- | -------------- |
953| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.|
954
955**Error codes**
956
957For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
958
959| ID| Error Message|
960| -------- | ---------------------------------------- |
961| 401      |  if parameter is invalid.         |
962| 13900012     | Permission denied.         |
963| 13900020     | Invalid argument.         |
964| 14000011       | System inner fail.         |
965
966**Example**
967
968```ts
969import dataSharePredicates from '@ohos.data.dataSharePredicates';
970import { BusinessError } from '@ohos.base';
971
972async function example() {
973  // Obtain the album named newAlbumName.
974  console.info('getAlbumsDemo');
975  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
976  predicates.equalTo('album_name', 'newAlbumName');
977  let fetchOptions: photoAccessHelper.FetchOptions = {
978    fetchColumns: [],
979    predicates: predicates
980  };
981  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions).then( async (fetchResult) => {
982    if (fetchResult === undefined) {
983      console.error('getAlbumsPromise fetchResult is undefined');
984      return;
985    }
986    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
987    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
988    fetchResult.close();
989  }).catch((err: BusinessError) => {
990    console.error('getAlbumsPromise failed with err: ' + err);
991  });
992}
993```
994
995### getHiddenAlbums<sup>11+</sup>
996
997getHiddenAlbums(mode: HiddenPhotosDisplayMode, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
998
999Obtains hidden albums based on the specified display mode and retrieval options. This API uses an asynchronous callback to return the result.
1000
1001**System API**: This is a system API.
1002
1003**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS
1004
1005**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1006
1007**Parameters**
1008
1009| Name  | Type                    | Mandatory| Description                     |
1010| -------- | ------------------------ | ---- | ------------------------- |
1011| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | Yes  | Display mode of hidden files. |
1012| options  | [FetchOptions](#fetchoptions)         | Yes  |  Options for retrieving the hidden files. |
1013| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
1014
1015**Error codes**
1016
1017For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1018
1019| ID| Error Message|
1020| -------- | ---------------------------------------- |
1021| 201      |  Permission denied.         |
1022| 202      |  Called by non-system application.         |
1023| 401      |  if parameter is invalid.         |
1024| 14000011       | System inner fail.         |
1025
1026**Example**
1027
1028```ts
1029import dataSharePredicates from '@ohos.data.dataSharePredicates';
1030
1031// Obtain the album newAlbumName that contains hidden files.
1032async function getHiddenAlbumsView() {
1033  console.info('getHiddenAlbumsViewDemo');
1034  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1035  predicates.equalTo('album_name', 'newAlbumName');
1036  let fetchOptions: photoAccessHelper.FetchOptions = {
1037    fetchColumns: [],
1038    predicates: predicates
1039  };
1040  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, fetchOptions,
1041    async (err, fetchResult) => {
1042      if (fetchResult === undefined) {
1043        console.error('getHiddenAlbumsViewCallback fetchResult is undefined');
1044        return;
1045      }
1046      let album = await fetchResult.getFirstObject();
1047      console.info('getHiddenAlbumsViewCallback successfully, album name: ' + album.albumName);
1048      fetchResult.close();
1049  });
1050}
1051```
1052
1053### getHiddenAlbums<sup>11+</sup>
1054
1055getHiddenAlbums(mode: HiddenPhotosDisplayMode, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
1056
1057Obtains hidden albums based on the specified display mode. This API uses an asynchronous callback to return the result.
1058
1059**System API**: This is a system API.
1060
1061**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS
1062
1063**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1064
1065**Parameters**
1066
1067| Name  | Type                    | Mandatory| Description                     |
1068| -------- | ------------------------ | ---- | ------------------------- |
1069| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | Yes  | Display mode of hidden files. |
1070| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
1071
1072**Error codes**
1073
1074For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1075
1076| ID| Error Message|
1077| -------- | ---------------------------------------- |
1078| 201      |  Permission denied.         |
1079| 202      |  Called by non-system application.         |
1080| 401      |  if parameter is invalid.         |
1081| 14000011       | System inner fail.         |
1082
1083**Example**
1084
1085```ts
1086import dataSharePredicates from '@ohos.data.dataSharePredicates';
1087
1088// Obtain the preset hidden album.
1089async function getSysHiddenAlbum() {
1090  console.info('getSysHiddenAlbumDemo');
1091  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE, async (err, fetchResult) => {
1092    if (fetchResult === undefined) {
1093      console.error('getSysHiddenAlbumCallback fetchResult is undefined');
1094      return;
1095    }
1096    let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject();
1097    console.info('getSysHiddenAlbumCallback successfully, albumUri: ' + hiddenAlbum.albumUri);
1098    fetchResult.close();
1099  });
1100}
1101
1102// Obtain the hidden albums displayed by album, that is, the albums with hidden files. Such albums do not include the preset hidden album and the albums in the trash.
1103async function getHiddenAlbumsView() {
1104  console.info('getHiddenAlbumsViewDemo');
1105  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, async (err, fetchResult) => {
1106    if (fetchResult === undefined) {
1107      console.error('getHiddenAlbumsViewCallback fetchResult is undefined');
1108      return;
1109    }
1110    let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects();
1111    console.info('getHiddenAlbumsViewCallback successfully, albums size: ' + albums.length);
1112
1113    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1114    let fetchOption: photoAccessHelper.FetchOptions = {
1115      fetchColumns: [],
1116      predicates: predicates
1117    };
1118    for (let i = 0; i < albums.length; i++) {
1119      // Obtain hidden files in the album.
1120      albums[i].getAssets(fetchOption, (err, assetFetchResult) => {
1121        console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount());
1122      });
1123    }
1124    fetchResult.close();
1125  });
1126}
1127```
1128
1129### getHiddenAlbums<sup>11+</sup>
1130
1131getHiddenAlbums(mode: HiddenPhotosDisplayMode, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
1132
1133Obtains hidden albums based on the specified display mode and retrieval options. This API uses a promise to return the result.
1134
1135**System API**: This is a system API.
1136
1137**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS
1138
1139**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1140
1141**Parameters**
1142
1143| Name  | Type                    | Mandatory| Description                     |
1144| -------- | ------------------------ | ---- | ------------------------- |
1145| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | Yes  | Display mode of hidden files. |
1146| options  | [FetchOptions](#fetchoptions)         | No  |  Options for retrieving the files. If this parameter is not specified, the files are retrieved based on the display mode of hidden files.     |
1147
1148**Return value**
1149
1150| Type                       | Description          |
1151| --------------------------- | -------------- |
1152| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.
1153
1154**Example**
1155
1156```ts
1157import dataSharePredicates from '@ohos.data.dataSharePredicates';
1158import { BusinessError } from '@ohos.base';
1159
1160// Obtain the preset hidden album.
1161async function getSysHiddenAlbum() {
1162  console.info('getSysHiddenAlbumDemo');
1163  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE)
1164    .then( async (fetchResult) => {
1165      if (fetchResult === undefined) {
1166        console.error('getSysHiddenAlbumPromise fetchResult is undefined');
1167        return;
1168      }
1169      let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject();
1170      console.info('getAlbumsPromise successfully, albumUri: ' + hiddenAlbum.albumUri);
1171      fetchResult.close();
1172    }).catch((err: BusinessError) => {
1173      console.error('getSysHiddenAlbumPromise failed with err: ' + err);
1174    });
1175}
1176
1177// Obtain the hidden albums displayed by album, that is, the albums with hidden files. Such albums do not include the preset hidden album and the albums in the trash.
1178async function getHiddenAlbumsView() {
1179  console.info('getHiddenAlbumsViewDemo');
1180  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE).then( async (fetchResult) => {
1181    if (fetchResult === undefined) {
1182      console.error('getHiddenAlbumsViewPromise fetchResult is undefined');
1183      return;
1184    }
1185    let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects();
1186    console.info('getHiddenAlbumsViewPromise successfully, albums size: ' + albums.length);
1187
1188    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1189    let fetchOption: photoAccessHelper.FetchOptions = {
1190      fetchColumns: [],
1191      predicates: predicates
1192    };
1193    for (let i = 0; i < albums.length; i++) {
1194      // Obtain hidden files in the album.
1195      albums[i].getAssets(fetchOption).then((assetFetchResult) => {
1196        console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount());
1197      }).catch((err: BusinessError) => {
1198        console.error('album get hidden assets failed with error: ' + err);
1199      });
1200    }
1201    fetchResult.close();
1202  }).catch((err: BusinessError) => {
1203    console.error('getHiddenAlbumsViewPromise failed with err: ' + err);
1204  });
1205}
1206```
1207
1208### deleteAssets<sup>(deprecated)</sup>
1209
1210deleteAssets(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
1211
1212Deletes media assets. This API uses an asynchronous callback to return the result. The deleted assets are moved to the trash.
1213
1214> **NOTE**
1215>
1216> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
1217
1218**System API**: This is a system API.
1219
1220**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1221
1222**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1223
1224**Parameters**
1225
1226| Name  | Type                     | Mandatory| Description      |
1227| -------- | ------------------------- | ---- | ---------- |
1228| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete.|
1229| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1230
1231**Error codes**
1232
1233For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1234
1235| ID| Error Message|
1236| -------- | ---------------------------------------- |
1237| 202   |  Called by non-system application.         |
1238| 401      |  if parameter is invalid.         |
1239| 13900012     | Permission denied.         |
1240| 13900020     | Invalid argument.         |
1241| 14000002       | Invalid uri.         |
1242| 14000011       | System inner fail.         |
1243
1244**Example**
1245
1246```ts
1247import dataSharePredicates from '@ohos.data.dataSharePredicates';
1248
1249async function example() {
1250  console.info('deleteAssetDemo');
1251  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1252  let fetchOptions: photoAccessHelper.FetchOptions = {
1253    fetchColumns: [],
1254    predicates: predicates
1255  };
1256  try {
1257    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1258    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1259    if (asset === undefined) {
1260      console.error('asset not exist');
1261      return;
1262    }
1263    phAccessHelper.deleteAssets([asset.uri], (err) => {
1264      if (err === undefined) {
1265        console.info('deleteAssets successfully');
1266      } else {
1267        console.error('deleteAssets failed with error: ' + err);
1268      }
1269    });
1270  } catch (err) {
1271    console.error('fetch failed, message =', err);
1272  }
1273}
1274```
1275
1276### deleteAssets<sup>(deprecated)</sup>
1277
1278deleteAssets(uriList: Array&lt;string&gt;): Promise&lt;void&gt;
1279
1280Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
1281
1282> **NOTE**
1283>
1284> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
1285
1286**System API**: This is a system API.
1287
1288**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1289
1290**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1291
1292**Parameters**
1293
1294| Name  | Type                     | Mandatory| Description      |
1295| -------- | ------------------------- | ---- | ---------- |
1296| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete.|
1297
1298**Return value**
1299
1300| Type                                   | Description             |
1301| --------------------------------------- | ----------------- |
1302| Promise&lt;void&gt;| Promise that returns no value.|
1303
1304**Error codes**
1305
1306For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1307
1308| ID| Error Message|
1309| -------- | ---------------------------------------- |
1310| 202   |  Called by non-system application.         |
1311| 401      |  if parameter is invalid.         |
1312| 13900012     | Permission denied.         |
1313| 13900020     | Invalid argument.         |
1314| 14000002       | Invalid uri.         |
1315| 14000011       | System inner fail.         |
1316
1317**Example**
1318
1319```ts
1320import dataSharePredicates from '@ohos.data.dataSharePredicates';
1321
1322async function example() {
1323  console.info('deleteDemo');
1324  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1325  let fetchOptions: photoAccessHelper.FetchOptions = {
1326    fetchColumns: [],
1327    predicates: predicates
1328  };
1329  try {
1330    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1331    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1332    if (asset === undefined) {
1333      console.error('asset not exist');
1334      return;
1335    }
1336    await phAccessHelper.deleteAssets([asset.uri]);
1337    console.info('deleteAssets successfully');
1338  } catch (err) {
1339    console.error('deleteAssets failed with error: ' + err);
1340  }
1341}
1342```
1343
1344### registerChange
1345
1346registerChange(uri: string, forChildUris: boolean, callback: Callback&lt;ChangeData&gt;) : void
1347
1348Registers listening for the specified URI. This API uses a callback to return the result.
1349
1350**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1351
1352**Parameters**
1353
1354| Name   | Type                                       | Mandatory| Description                                                        |
1355| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
1356| uri       | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](#defaultchangeuri).|
1357| 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.|
1358| callback  | Callback&lt;[ChangeData](#changedata)&gt; | Yes  | Callback invoked to return the [ChangeData](#changedata). <br>**NOTE**<br>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.|
1359
1360**Error codes**
1361
1362For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1363
1364| ID| Error Message|
1365| -------- | ---------------------------------------- |
1366| 401      |  if parameter is invalid.         |
1367| 13900012     | Permission denied.         |
1368| 13900020     | Invalid argument.         |
1369
1370**Example**
1371
1372```ts
1373import dataSharePredicates from '@ohos.data.dataSharePredicates';
1374
1375async function example() {
1376  console.info('registerChangeDemo');
1377  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1378  let fetchOptions: photoAccessHelper.FetchOptions = {
1379    fetchColumns: [],
1380    predicates: predicates
1381  };
1382  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1383  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1384  if (photoAsset !== undefined) {
1385    console.info('photoAsset.displayName : ' + photoAsset.displayName);
1386  }
1387  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
1388      console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1389    //file had changed, do something
1390  }
1391  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
1392      console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1393    //file had changed, do something
1394  }
1395  // Register onCallback1.
1396  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
1397  // Register onCallback2.
1398  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
1399
1400  photoAsset.setFavorite(true, (err) => {
1401    if (err === undefined) {
1402      console.info('setFavorite successfully');
1403    } else {
1404      console.error('setFavorite failed with error:' + err);
1405    }
1406  });
1407}
1408```
1409
1410### unRegisterChange
1411
1412unRegisterChange(uri: string, callback?: Callback&lt;ChangeData&gt;): void
1413
1414Unregisters 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.
1415
1416**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1417
1418**Parameters**
1419
1420| Name  | Type                                       | Mandatory| Description                                                        |
1421| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
1422| uri      | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](#defaultchangeuri).|
1423| callback | Callback&lt;[ChangeData](#changedata)&gt; | No  | Callback to unregister. If this parameter is not specified, all the callbacks for listening for the URI will be canceled. <br>**NOTE**: The specified callback unregistered will not be invoked when the data changes.|
1424
1425**Error codes**
1426
1427For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1428
1429| ID| Error Message|
1430| -------- | ---------------------------------------- |
1431| 401      |  if parameter is invalid.         |
1432| 13900012     | Permission denied.         |
1433| 13900020     | Invalid argument.         |
1434
1435**Example**
1436
1437```ts
1438import dataSharePredicates from '@ohos.data.dataSharePredicates';
1439
1440async function example() {
1441  console.info('offDemo');
1442  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1443  let fetchOptions: photoAccessHelper.FetchOptions = {
1444    fetchColumns: [],
1445    predicates: predicates
1446  };
1447  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1448  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1449  if (photoAsset !== undefined) {
1450    console.info('photoAsset.displayName : ' + photoAsset.displayName);
1451  }
1452  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
1453    console.info('onCallback1 on');
1454  }
1455  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
1456    console.info('onCallback2 on');
1457  }
1458  // Register onCallback1.
1459  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
1460  // Register onCallback2.
1461  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
1462  // Unregister the listening of onCallback1.
1463  phAccessHelper.unRegisterChange(photoAsset.uri, onCallback1);
1464  photoAsset.setFavorite(true, (err) => {
1465    if (err === undefined) {
1466      console.info('setFavorite successfully');
1467    } else {
1468      console.error('setFavorite failed with error:' + err);
1469    }
1470  });
1471}
1472```
1473
1474### createDeleteRequest<sup>(deprecated)</sup>
1475
1476createDeleteRequest(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
1477
1478Creates 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.
1479
1480> **NOTE**
1481>
1482> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
1483
1484**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1485
1486**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1487
1488**Parameters**
1489
1490| Name  | Type                     | Mandatory| Description      |
1491| -------- | ------------------------- | ---- | ---------- |
1492| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
1493| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1494
1495**Error codes**
1496
1497For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1498
1499| ID| Error Message|
1500| -------- | ---------------------------------------- |
1501| 401      |  if parameter is invalid.         |
1502| 13900012     | Permission denied.         |
1503| 13900020     | Invalid argument.         |
1504| 14000011       | System inner fail.         |
1505
1506**Example**
1507
1508```ts
1509import dataSharePredicates from '@ohos.data.dataSharePredicates';
1510
1511async function example() {
1512  console.info('createDeleteRequestDemo');
1513  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1514  let fetchOptions: photoAccessHelper.FetchOptions = {
1515    fetchColumns: [],
1516    predicates: predicates
1517  };
1518  try {
1519    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1520    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1521    if (asset === undefined) {
1522      console.error('asset not exist');
1523      return;
1524    }
1525    phAccessHelper.createDeleteRequest([asset.uri], (err) => {
1526      if (err === undefined) {
1527        console.info('createDeleteRequest successfully');
1528      } else {
1529        console.error('createDeleteRequest failed with error: ' + err);
1530      }
1531    });
1532  } catch (err) {
1533    console.info('fetch failed, message =', err);
1534  }
1535}
1536```
1537
1538### createDeleteRequest<sup>(deprecated)</sup>
1539
1540createDeleteRequest(uriList: Array&lt;string&gt;): Promise&lt;void&gt;
1541
1542Creates 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.
1543
1544> **NOTE**
1545>
1546> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
1547
1548**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1549
1550**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1551
1552**Parameters**
1553
1554| Name  | Type                     | Mandatory| Description      |
1555| -------- | ------------------------- | ---- | ---------- |
1556| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
1557
1558**Return value**
1559
1560| Type                                   | Description             |
1561| --------------------------------------- | ----------------- |
1562| Promise&lt;void&gt;| Promise that returns no value.|
1563
1564**Error codes**
1565
1566For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1567
1568| ID| Error Message|
1569| -------- | ---------------------------------------- |
1570| 401      |  if parameter is invalid.         |
1571| 13900012     | Permission denied.         |
1572| 13900020     | Invalid argument.         |
1573| 14000011       | System inner fail.         |
1574
1575**Example**
1576
1577```ts
1578import dataSharePredicates from '@ohos.data.dataSharePredicates';
1579
1580async function example() {
1581  console.info('createDeleteRequestDemo');
1582  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1583  let fetchOptions: photoAccessHelper.FetchOptions = {
1584    fetchColumns: [],
1585    predicates: predicates
1586  };
1587  try {
1588    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1589    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1590    if (asset === undefined) {
1591      console.error('asset not exist');
1592      return;
1593    }
1594    await phAccessHelper.createDeleteRequest([asset.uri]);
1595    console.info('createDeleteRequest successfully');
1596  } catch (err) {
1597    console.error('createDeleteRequest failed with error: ' + err);
1598  }
1599}
1600```
1601
1602### getPhotoIndex
1603
1604getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback&lt;number&gt;): void
1605
1606Obtains the index of an image or video in an album. This API uses an asynchronous callback to return the result.
1607
1608**System API**: This is a system API.
1609
1610**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1611
1612**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1613
1614**Parameters**
1615
1616| Name  | Type                     | Mandatory| Description      |
1617| -------- | ------------------------- | ---- | ---------- |
1618| photoUri | string | Yes  | URI of the media asset whose index is to be obtained.|
1619| albumUri | string | Yes  | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default.  |
1620| options  | [FetchOptions](#fetchoptions)       | Yes  |  Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search criteria or sorting modes are set, the API cannot be called successfully.     |
1621| callback | AsyncCallback&lt;number&gt;| Yes  | Callback invoked to return the index obtained.|
1622
1623**Error codes**
1624
1625For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1626
1627| ID| Error Message|
1628| -------- | ---------------------------------------- |
1629| 202     |  Called by non-system application.         |
1630| 401      |  if parameter is invalid.         |
1631| 13900012     | Permission denied.         |
1632| 13900020     | Invalid argument.         |
1633| 14000011       | System inner fail.         |
1634
1635**Example**
1636
1637```ts
1638import dataSharePredicates from '@ohos.data.dataSharePredicates';
1639
1640async function example() {
1641  try {
1642    console.info('getPhotoIndexDemo');
1643    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1644    let fetchOp: photoAccessHelper.FetchOptions = {
1645      fetchColumns: [],
1646      predicates: predicatesForGetAsset
1647    };
1648    // Obtain the uri of the album
1649    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp);
1650    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
1651    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1652    predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED);
1653    let fetchOptions: photoAccessHelper.FetchOptions = {
1654      fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED],
1655      predicates: predicates
1656    };
1657    let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
1658    let expectIndex = 1;
1659    // Obtain the uri of the second file
1660    let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex);
1661
1662    phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => {
1663      if (err === undefined) {
1664        console.info(`getPhotoIndex successfully and index is : ${index}`);
1665      } else {
1666        console.info(`getPhotoIndex failed; error: ${err}`);
1667      }
1668    });
1669  } catch (error) {
1670    console.info(`getPhotoIndex failed; error: ${error}`);
1671  }
1672}
1673```
1674
1675### getPhotoIndex
1676
1677getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise&lt;number&gt;
1678
1679Obtains the index of an image or video in an album. This API uses a promise to return the result.
1680
1681**System API**: This is a system API.
1682
1683**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1684
1685**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1686
1687**Parameters**
1688
1689| Name  | Type                     | Mandatory| Description      |
1690| -------- | ------------------------- | ---- | ---------- |
1691| photoUri | string | Yes  | URI of the media asset whose index is to be obtained.|
1692| albumUri | string | Yes  | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default.  |
1693| options  | [FetchOptions](#fetchoptions)       | Yes  |  Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search criteria or sorting modes are set, the API cannot be called successfully.     |
1694
1695**Return value**
1696
1697| Type                                   | Description             |
1698| --------------------------------------- | ----------------- |
1699| Promise&lt;number&gt;| Promise used to return the index obtained.|
1700
1701**Error codes**
1702
1703For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1704
1705| ID| Error Message|
1706| -------- | ---------------------------------------- |
1707| 202     |  Called by non-system application.         |
1708| 401      |  if parameter is invalid.         |
1709| 13900012     | Permission denied.         |
1710| 13900020     | Invalid argument.         |
1711| 14000011       | System inner fail.         |
1712
1713**Example**
1714
1715```ts
1716import dataSharePredicates from '@ohos.data.dataSharePredicates';
1717import { BusinessError } from '@ohos.base';
1718
1719async function example() {
1720  try {
1721    console.info('getPhotoIndexDemo');
1722    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1723    let fetchOp: photoAccessHelper.FetchOptions = {
1724      fetchColumns: [],
1725      predicates: predicatesForGetAsset
1726    };
1727    // Obtain the uri of the album
1728    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp);
1729    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
1730    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1731    predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED);
1732    let fetchOptions: photoAccessHelper.FetchOptions = {
1733      fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED],
1734      predicates: predicates
1735    };
1736    let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
1737    let expectIndex = 1;
1738    // Obtain the uri of the second file
1739    let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex);
1740    phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions).then((index) => {
1741      console.info(`getPhotoIndex successfully and index is : ${index}`);
1742    }).catch((err: BusinessError) => {
1743      console.info(`getPhotoIndex failed; error: ${err}`);
1744    });
1745  } catch (error) {
1746    console.info(`getPhotoIndex failed; error: ${error}`);
1747  }
1748}
1749```
1750
1751### saveFormInfo<sup>11+</sup>
1752
1753saveFormInfo(info:FormInfo, callback: AsyncCallback&lt;void&gt;):void
1754
1755Saves a Gallery widget. This API uses an asynchronous callback to return the result.
1756
1757**System API**: This is a system API.
1758
1759**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1760
1761**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1762
1763**Parameters**
1764
1765| Name  | Type                    | Mandatory| Description                     |
1766| -------- | ------------------------ | ---- | ------------------------- |
1767| info  | [FormInfo](#forminfo11)        | Yes  | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget.             |
1768| callback |  AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1769
1770**Error codes**
1771
1772For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1773
1774| ID| Error Message|
1775| -------- | ---------------------------------------- |
1776| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1777| 202   | Permission verification failed, application which is not a system application uses system API.         |
1778| 401   | if the argument is invalid.         |
1779| 14000011       | System inner fail.         |
1780
1781
1782**Example**
1783
1784```ts
1785import dataSharePredicates from '@ohos.data.dataSharePredicates';
1786import { BusinessError } from '@ohos.base';
1787
1788async function example() {
1789  console.info('saveFormInfoDemo');
1790  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1791  let fetchOptions: photoAccessHelper.FetchOptions = {
1792    fetchColumns: [],
1793    predicates: predicates
1794  };
1795  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1796  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1797
1798  let info: photoAccessHelper.FormInfo = {
1799    // formId is a string consisting of only digits. uri indicates the URI of the image in Gallery. If there is no image in Gallery, uri must be an empty string.
1800    formId : "20230116123",
1801    uri: photoAsset.uri,
1802  }
1803
1804  phAccessHelper.saveFormInfo(info, async (err: BusinessError) => {
1805    if (err == undefined) {
1806      console.info('saveFormInfo success');
1807    } else {
1808      console.error('saveFormInfo fail' + err);
1809    }
1810  });
1811}
1812```
1813
1814### saveFormInfo<sup>11+</sup>
1815
1816saveFormInfo(info:FormInfo):Promise&lt;void&gt;
1817
1818Saves a Gallery widget. This API uses a promise to return the result.
1819
1820**System API**: This is a system API.
1821
1822**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1823
1824**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1825
1826**Parameters**
1827
1828| Name  | Type                    | Mandatory| Description                     |
1829| -------- | ------------------------ | ---- | ------------------------- |
1830| info  | [FormInfo](#forminfo11)        | Yes  | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget.             |
1831
1832**Return value**
1833
1834| Type                                   | Description             |
1835| --------------------------------------- | ----------------- |
1836| Promise&lt;void&gt;| Promise that returns no value.|
1837
1838**Error codes**
1839
1840For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1841
1842| ID| Error Message|
1843| -------- | ---------------------------------------- |
1844| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1845| 202   | Permission verification failed, application which is not a system application uses system API.         |
1846| 401   | if the argument is invalid.         |
1847| 14000011       | System inner fail.         |
1848
1849**Example**
1850
1851```ts
1852import dataSharePredicates from '@ohos.data.dataSharePredicates';
1853import { BusinessError } from '@ohos.base';
1854
1855async function example() {
1856  console.info('saveFormInfoDemo');
1857  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1858  let fetchOptions: photoAccessHelper.FetchOptions = {
1859    fetchColumns: [],
1860    predicates: predicates
1861  };
1862  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1863  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1864
1865  let info: photoAccessHelper.FormInfo = {
1866    // formId is a string consisting of only digits. uri indicates the URI of the image in Gallery. If there is no image in Gallery, uri must be an empty string.
1867    formId: "20230116123",
1868    uri: photoAsset.uri,
1869  }
1870
1871  phAccessHelper.saveFormInfo(info).then(() => {
1872    console.info('saveFormInfo successfully');
1873  }).catch((err: BusinessError) => {
1874    console.info('saveFormInfo failed' + err);
1875  });
1876}
1877```
1878
1879### removeFormInfo<sup>11+</sup>
1880
1881removeFormInfo(info:FormInfo, callback: AsyncCallback&lt;void&gt;):void
1882
1883Removes a Gallery widget. This API uses an asynchronous callback to return the result.
1884
1885**System API**: This is a system API.
1886
1887**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1888
1889**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1890
1891**Parameters**
1892
1893| Name  | Type                    | Mandatory| Description                     |
1894| -------- | ------------------------ | ---- | ------------------------- |
1895| info  | [FormInfo](#forminfo11)        | Yes  |  Information about the Gallery widget to remove, which includes the ID of the widget and the URI of the image bound to the widget.             |
1896| callback |  AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1897
1898**Error codes**
1899
1900For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1901
1902| ID| Error Message|
1903| -------- | ---------------------------------------- |
1904| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1905| 202   | Permission verification failed, application which is not a system application uses system API.         |
1906| 401   | if the argument is invalid.         |
1907| 14000011       | System inner fail.         |
1908
1909**Example**
1910
1911```ts
1912import { BusinessError } from '@ohos.base';
1913
1914async function example() {
1915  console.info('removeFormInfoDemo');
1916  let info: photoAccessHelper.FormInfo = {
1917    // formId is a string consisting of only digits. When removing a widget, leave uri empty.
1918    formId: "20230116123",
1919    uri: "",
1920  }
1921
1922  phAccessHelper.removeFormInfo(info, async (err: BusinessError) => {
1923    if (err == undefined) {
1924      console.info('removeFormInfo success');
1925    } else {
1926      console.error('removeFormInfo fail' + err);
1927    }
1928  });
1929}
1930```
1931
1932### removeFormInfo<sup>11+</sup>
1933
1934removeFormInfo(info:FormInfo):Promise&lt;void&gt;
1935
1936Removes a Gallery widget. This API uses a promise to return the result.
1937
1938**System API**: This is a system API.
1939
1940**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1941
1942**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1943
1944**Parameters**
1945
1946| Name  | Type                    | Mandatory| Description                     |
1947| -------- | ------------------------ | ---- | ------------------------- |
1948| info  | [FormInfo](#forminfo11)        | Yes  |  Information about the Gallery widget to remove, which includes the ID of the widget and the URI of the image bound to the widget.             |
1949
1950**Return value**
1951
1952| Type                                   | Description             |
1953| --------------------------------------- | ----------------- |
1954| Promise&lt;void&gt;| Promise that returns no value.|
1955
1956**Error codes**
1957
1958For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1959
1960| ID| Error Message|
1961| -------- | ---------------------------------------- |
1962| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1963| 202   | Permission verification failed, application which is not a system application uses system API.         |
1964| 401   | if the argument is invalid.         |
1965| 14000011       | System inner fail.         |
1966
1967**Example**
1968
1969```ts
1970import { BusinessError } from '@ohos.base';
1971
1972async function example() {
1973  console.info('removeFormInfoDemo');
1974  let info: photoAccessHelper.FormInfo = {
1975    // formId is a string consisting of only digits. When removing a widget, leave uri empty.
1976    formId: "20230116123",
1977    uri: "",
1978  }
1979
1980  phAccessHelper.removeFormInfo(info).then(() => {
1981    console.info('removeFormInfo successfully');
1982  }).catch((err: BusinessError) => {
1983    console.info('removeFormInfo failed' + err);
1984  });
1985}
1986```
1987
1988### applyChanges<sup>11+</sup>
1989
1990applyChanges(mediaChangeRequest: MediaChangeRequest): Promise&lt;void&gt;
1991
1992Applies media changes. This API uses a promise to return the result.
1993
1994**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1995
1996**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1997
1998**Parameters**
1999
2000| Name  | Type                    | Mandatory| Description                     |
2001| -------- | ------------------------ | ---- | ------------------------- |
2002| mediaChangeRequest  | [MediaChangeRequest](#mediachangerequest11)  | Yes |  Request for asset changes or album changes.|
2003
2004**Return value**
2005
2006| Type                                   | Description             |
2007| --------------------------------------- | ----------------- |
2008| Promise&lt;void&gt;| Promise that returns no value.|
2009
2010**Error codes**
2011
2012For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2013
2014| ID| Error Message|
2015| -------- | ---------------------------------------- |
2016| 201   | Permission denied.         |
2017| 401   | if parameter is invalid.   |
2018| 14000011  | System inner fail.     |
2019
2020**Example**
2021
2022This API depends on the [MediaChangeRequest](#mediachangerequest11) object. For details about the sample code, see [MediaAssetChangeRequest](#mediaassetchangerequest11), [MediaAssetsChangeRequest](#mediaassetschangerequest11), and [MediaAlbumChangeRequest](#mediaalbumchangerequest11).
2023
2024### release
2025
2026release(callback: AsyncCallback&lt;void&gt;): void
2027
2028Releases this **PhotoAccessHelper** instance. This API uses an asynchronous callback to return the result.
2029Call this API when the APIs of the **PhotoAccessHelper** instance are no longer used.
2030
2031**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2032
2033**Parameters**
2034
2035| Name  | Type                     | Mandatory| Description                |
2036| -------- | ------------------------- | ---- | -------------------- |
2037| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2038
2039**Error codes**
2040
2041For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2042
2043| ID| Error Message|
2044| -------- | ---------------------------------------- |
2045| 401      |  if parameter is invalid.         |
2046| 13900020     | Invalid argument.         |
2047| 14000011       | System inner fail.         |
2048
2049**Example**
2050
2051```ts
2052async function example() {
2053  console.info('releaseDemo');
2054  phAccessHelper.release((err) => {
2055    if (err !== undefined) {
2056      console.error('release failed. message = ', err);
2057    } else {
2058      console.info('release ok.');
2059    }
2060  });
2061}
2062```
2063
2064### release
2065
2066release(): Promise&lt;void&gt;
2067
2068Releases this **PhotoAccessHelper** instance. This API uses a promise to return the result.
2069Call this API when the APIs of the **PhotoAccessHelper** instance are no longer used.
2070
2071**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2072
2073**Return value**
2074
2075| Type               | Description                             |
2076| ------------------- | --------------------------------- |
2077| Promise&lt;void&gt; | Promise that returns no value.|
2078
2079**Error codes**
2080
2081For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2082
2083| ID| Error Message|
2084| -------- | ---------------------------------------- |
2085| 401      |  if parameter is invalid.         |
2086| 13900020     | Invalid argument.         |
2087| 14000011       | System inner fail.         |
2088
2089**Example**
2090
2091```ts
2092async function example() {
2093  console.info('releaseDemo');
2094  try {
2095    await phAccessHelper.release();
2096    console.info('release ok.');
2097  } catch (err) {
2098    console.error('release failed. message = ', err);
2099  }
2100}
2101```
2102
2103## PhotoAsset
2104
2105Provides APIs for encapsulating file asset attributes.
2106
2107### Attributes
2108
2109**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2110
2111| Name                     | Type                    | Readable| Writable| Description                                                  |
2112| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
2113| uri                       | string                   | Yes  | No  | Media asset URI, for example, **file://media/Photo/1/IMG_datetime_0001/displayName.jpg**. For details, see [Media File URI](../../file-management/user-file-uri-intro.md#media-file-uri).        |
2114| photoType   | [PhotoType](#phototype) | Yes  | No  | Type of the file.                                              |
2115| displayName               | string                   | Yes  | No  | File name, including the file name extension, to display.                                |
2116
2117### get
2118
2119get(member: string): MemberType;
2120
2121Obtains a **PhotoAsset** member parameter.
2122
2123**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2124
2125**Parameters**
2126
2127| Name     | Type                       | Mandatory  | Description   |
2128| -------- | ------------------------- | ---- | ----- |
2129| member | string | Yes   | Name of the member parameter to obtain. Except **uri**, **photoType**, and **displayName**, you need to pass in [PhotoKeys](#photokeys) in **fetchColumns** in **get()**. For example, to obtain the title attribute, set **fetchColumns: ['title']**.|
2130
2131**Return value**
2132
2133| Type               | Description                             |
2134| ------------------- | --------------------------------- |
2135| [MemberType](#membertype) | **PhotoAsset** member parameter obtained.|
2136
2137**Error codes**
2138
2139For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2140
2141| ID| Error Message|
2142| -------- | ---------------------------------------- |
2143| 401    | if parameter is invalid.         |
2144| 13900020     | Invalid argument.         |
2145| 14000014     | Member is not a valid PhotoKey.         |
2146
2147**Example**
2148
2149```ts
2150import dataSharePredicates from '@ohos.data.dataSharePredicates';
2151
2152async function example() {
2153  console.info('photoAssetGetDemo');
2154  try {
2155    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2156    let fetchOption: photoAccessHelper.FetchOptions = {
2157      fetchColumns: ['title'],
2158      predicates: predicates
2159    };
2160    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2161    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2162    let title: photoAccessHelper.PhotoKeys = photoAccessHelper.PhotoKeys.TITLE;
2163    let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title.toString());
2164    console.info('photoAsset Get photoAssetTitle = ', photoAssetTitle);
2165  } catch (err) {
2166    console.error('release failed. message = ', err);
2167  }
2168}
2169```
2170
2171### set
2172
2173set(member: string, value: string): void
2174
2175Sets a **PhotoAsset** member parameter.
2176
2177**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2178
2179**Parameters**
2180
2181| Name     | Type                       | Mandatory  | Description   |
2182| -------- | ------------------------- | ---- | ----- |
2183| member | string | Yes   | Name of the member parameter to set. For example, **[PhotoKeys](#photokeys).TITLE**.|
2184| value | string | Yes   | Member parameter to set. Only the value of **[PhotoKeys](#photokeys).TITLE** can be modified.|
2185
2186**Error codes**
2187
2188For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2189
2190| ID| Error Message|
2191| -------- | ---------------------------------------- |
2192| 401    | if parameter is invalid.         |
2193| 13900020     | Invalid argument.         |
2194| 14000014     | Member is not a valid PhotoKey.         |
2195
2196**Example**
2197
2198```ts
2199import dataSharePredicates from '@ohos.data.dataSharePredicates';
2200
2201async function example() {
2202  console.info('photoAssetSetDemo');
2203  try {
2204    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2205    let fetchOption: photoAccessHelper.FetchOptions = {
2206      fetchColumns: ['title'],
2207      predicates: predicates
2208    };
2209    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2210    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2211    let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
2212    photoAsset.set(title, 'newTitle');
2213  } catch (err) {
2214    console.error('release failed. message = ', err);
2215  }
2216}
2217```
2218
2219### commitModify
2220
2221commitModify(callback: AsyncCallback&lt;void&gt;): void
2222
2223Commits the modification on the file metadata to the database. This API uses an asynchronous callback to return the result.
2224
2225**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2226
2227**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2228
2229**Parameters**
2230
2231| Name     | Type                       | Mandatory  | Description   |
2232| -------- | ------------------------- | ---- | ----- |
2233| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
2234
2235**Error codes**
2236
2237For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2238
2239| ID| Error Message|
2240| -------- | ---------------------------------------- |
2241| 401    | if values to commit is invalid.         |
2242| 13900012     | Permission denied.         |
2243| 13900020     | Invalid argument.         |
2244| 14000001      | Invalid display name.         |
2245| 14000011       | System inner fail.         |
2246
2247**Example**
2248
2249```ts
2250import dataSharePredicates from '@ohos.data.dataSharePredicates';
2251
2252async function example() {
2253  console.info('commitModifyDemo');
2254  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2255  let fetchOption: photoAccessHelper.FetchOptions = {
2256    fetchColumns: ['title'],
2257    predicates: predicates
2258  };
2259  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2260  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2261  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
2262  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
2263  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
2264  photoAsset.set(title, 'newTitle2');
2265  photoAsset.commitModify((err) => {
2266    if (err === undefined) {
2267      let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
2268      console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
2269    } else {
2270      console.error('commitModify failed, message =', err);
2271    }
2272  });
2273}
2274```
2275
2276### commitModify
2277
2278commitModify(): Promise&lt;void&gt;
2279
2280Commits the modification on the file metadata to the database. This API uses a promise to return the result.
2281
2282**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2283
2284**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2285
2286**Return value**
2287
2288| Type                 | Description        |
2289| ------------------- | ---------- |
2290| Promise&lt;void&gt; | Promise that returns no value.|
2291
2292**Error codes**
2293
2294For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2295
2296| ID| Error Message|
2297| -------- | ---------------------------------------- |
2298| 401    | if values to commit is invalid.         |
2299| 13900012     | Permission denied.         |
2300| 13900020     | Invalid argument.         |
2301| 14000001      | Invalid display name.         |
2302| 14000011       | System inner fail.         |
2303
2304**Example**
2305
2306```ts
2307import dataSharePredicates from '@ohos.data.dataSharePredicates';
2308
2309async function example() {
2310  console.info('commitModifyDemo');
2311  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2312  let fetchOption: photoAccessHelper.FetchOptions = {
2313    fetchColumns: ['title'],
2314    predicates: predicates
2315  };
2316  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2317  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2318  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
2319  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
2320  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
2321  photoAsset.set(title, 'newTitle3');
2322  try {
2323    await photoAsset.commitModify();
2324    let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
2325    console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
2326  } catch (err) {
2327    console.error('release failed. message = ', err);
2328  }
2329}
2330```
2331
2332### open<sup>(deprecated)</sup>
2333
2334open(mode: string, callback: AsyncCallback&lt;number&gt;): void
2335
2336Opens this file asset. This API uses an asynchronous callback to return the result.
2337
2338> **NOTE**
2339>
2340> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided.
2341
2342> **NOTE**<br>A file can be opened in only one mode at a time. Use **close()** to close the FD returned when it is not required.
2343
2344**System API**: This is a system API.
2345
2346**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO
2347
2348**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2349
2350**Parameters**
2351
2352| Name     | Type                         | Mandatory  | Description                                 |
2353| -------- | --------------------------- | ---- | ----------------------------------- |
2354| mode     | string                      | Yes   | Mode for opening the file, which can be **'r'** (read-only), **'w'** (write-only), or **'rw'** (read/write).|
2355| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the file descriptor (FD) of the file opened.                           |
2356
2357**Error codes**
2358
2359For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2360
2361| ID| Error Message|
2362| -------- | ---------------------------------------- |
2363| 202     |  Called by non-system application.         |
2364| 401       |  if parameter is invalid.         |
2365| 13900012     | Permission denied.         |
2366| 13900020     | Invalid argument.         |
2367| 14000011       | System inner fail.         |
2368
2369**Example**
2370
2371```ts
2372async function example() {
2373  console.info('Open demo');
2374  let testFileName: string = 'testFile' + Date.now() + '.jpg';
2375  let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
2376  photoAsset.open('rw', (err, fd) => {
2377    if (fd !== undefined) {
2378      console.info('File fd' + fd);
2379      photoAsset.close(fd);
2380    } else {
2381      console.error('Open file err' + err);
2382    }
2383  });
2384}
2385```
2386
2387### open<sup>(deprecated)</sup>
2388
2389open(mode: string): Promise&lt;number&gt;
2390
2391Opens this file asset. This API uses a promise to return the result.
2392
2393> **NOTE**
2394>
2395> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided.
2396
2397> **NOTE**<br>A file can be opened in only one mode at a time. Use **close()** to close the FD returned when it is not required.
2398
2399**System API**: This is a system API.
2400
2401**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO
2402
2403**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2404
2405**Parameters**
2406
2407| Name | Type    | Mandatory  | Description                                 |
2408| ---- | ------ | ---- | ----------------------------------- |
2409| mode | string | Yes   | Mode for opening the file, which can be **'r'** (read-only), **'w'** (write-only), or **'rw'** (read/write).|
2410
2411**Return value**
2412
2413| Type                   | Description           |
2414| --------------------- | ------------- |
2415| Promise&lt;number&gt; | Promise used to return the FD of the file opened.|
2416
2417**Error codes**
2418
2419For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2420
2421| ID| Error Message|
2422| -------- | ---------------------------------------- |
2423| 202     |  Called by non-system application.         |
2424| 401       |  if parameter is invalid.         |
2425| 13900012     | Permission denied.         |
2426| 13900020     | Invalid argument.         |
2427| 14000011       | System inner fail.         |
2428
2429**Example**
2430
2431```ts
2432async function example() {
2433  console.info('Open demo');
2434  try {
2435    let testFileName: string = 'testFile' + Date.now() + '.jpg';
2436    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
2437    let fd: number = await photoAsset.open('rw');
2438    if (fd !== undefined) {
2439      console.info('File fd' + fd);
2440      photoAsset.close(fd);
2441    } else {
2442      console.error('Open file fail');
2443    }
2444  } catch (err) {
2445    console.error('Open demo err' + err);
2446  }
2447}
2448```
2449
2450### getReadOnlyFd<sup>(deprecated)</sup>
2451
2452getReadOnlyFd(callback: AsyncCallback&lt;number&gt;): void
2453
2454Opens this file in read-only mode. This API uses an asynchronous callback to return the result.
2455
2456> **NOTE**
2457>
2458> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided.
2459
2460> **NOTE**<br>The returned FD must be closed when it is not required.
2461
2462**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2463
2464**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2465
2466**Parameters**
2467
2468| Name     | Type                         | Mandatory  | Description                                 |
2469| -------- | --------------------------- | ---- | ----------------------------------- |
2470| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the file descriptor (FD) of the file opened.                           |
2471
2472**Error codes**
2473
2474For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2475
2476| ID| Error Message|
2477| -------- | ---------------------------------------- |
2478| 401       |  if parameter is invalid.         |
2479| 13900012     | Permission denied.         |
2480| 13900020     | Invalid argument.         |
2481| 14000011       | System inner fail.         |
2482
2483**Example**
2484
2485```ts
2486async function example() {
2487  console.info('getReadOnlyFdDemo');
2488  // Ensure that there are images and video files in the device.
2489  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2490  let fetchOptions: photoAccessHelper.FetchOptions = {
2491    fetchColumns: [],
2492    predicates: predicates
2493  };
2494  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2495  let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
2496  photoAsset.getReadOnlyFd((err, fd) => {
2497    if (fd !== undefined) {
2498      console.info('File fd' + fd);
2499      photoAsset.close(fd);
2500    } else {
2501      console.error('getReadOnlyFd err' + err);
2502    }
2503  });
2504}
2505```
2506
2507### getReadOnlyFd<sup>(deprecated)</sup>
2508
2509getReadOnlyFd(): Promise&lt;number&gt;
2510
2511Opens this file in read-only mode. This API uses a promise to return the result.
2512
2513> **NOTE**
2514>
2515> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided.
2516
2517> **NOTE**<br>The returned FD must be closed when it is not required.
2518
2519**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2520
2521**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2522
2523**Return value**
2524
2525| Type                   | Description           |
2526| --------------------- | ------------- |
2527| Promise&lt;number&gt; | Promise used to return the FD of the file opened.|
2528
2529**Error codes**
2530
2531For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2532
2533| ID| Error Message|
2534| -------- | ---------------------------------------- |
2535| 401       |  if parameter is invalid.         |
2536| 13900012     | Permission denied.         |
2537| 13900020     | Invalid argument.         |
2538| 14000011       | System inner fail.         |
2539
2540**Example**
2541
2542```ts
2543async function example() {
2544  console.info('getReadOnlyFdDemo');
2545  try {
2546    // Ensure that there are images and video files in the device.
2547    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2548    let fetchOptions: photoAccessHelper.FetchOptions = {
2549      fetchColumns: [],
2550      predicates: predicates
2551    };
2552    let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2553    let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
2554    let fd: number = await photoAsset.getReadOnlyFd();
2555    if (fd !== undefined) {
2556      console.info('File fd' + fd);
2557      photoAsset.close(fd);
2558    } else {
2559      console.error('getReadOnlyFd fail');
2560    }
2561  } catch (err) {
2562    console.error('getReadOnlyFd demo err' + err);
2563  }
2564}
2565```
2566
2567### close<sup>(deprecated)</sup>
2568
2569close(fd: number, callback: AsyncCallback&lt;void&gt;): void
2570
2571Closes a file. This API uses an asynchronous callback to return the result.
2572
2573> **NOTE**
2574>
2575> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided. The corresponding **close** API is also deprecated.
2576
2577**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2578
2579**Parameters**
2580
2581| Name     | Type                       | Mandatory  | Description   |
2582| -------- | ------------------------- | ---- | ----- |
2583| fd       | number                    | Yes   | FD of the file to close.|
2584| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
2585
2586**Error codes**
2587
2588For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2589
2590| ID| Error Message|
2591| -------- | ---------------------------------------- |
2592| 401       |  if parameter is invalid.         |
2593| 13900020     | Invalid argument.         |
2594| 14000011       | System inner fail.         |
2595
2596**Example**
2597
2598```ts
2599import dataSharePredicates from '@ohos.data.dataSharePredicates';
2600
2601async function example() {
2602  console.info('closeDemo');
2603  try {
2604    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2605    let fetchOption: photoAccessHelper.FetchOptions = {
2606      fetchColumns: [],
2607      predicates: predicates
2608    };
2609    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2610    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2611    let fd: number = await photoAsset.open('rw');
2612    console.info('file fd', fd);
2613    photoAsset.close(fd, (err) => {
2614      if (err === undefined) {
2615        console.info('asset close succeed.');
2616      } else {
2617        console.error('close failed, message = ' + err);
2618      }
2619    });
2620  } catch (err) {
2621    console.error('close failed, message = ' + err);
2622  }
2623}
2624```
2625
2626### close<sup>(deprecated)</sup>
2627
2628close(fd: number): Promise&lt;void&gt;
2629
2630Closes a file. This API uses a promise to return the result.
2631
2632> **NOTE**
2633>
2634> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the handle of a media file is no longer provided. The corresponding **close** API is also deprecated.
2635
2636**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2637
2638**Parameters**
2639
2640| Name | Type    | Mandatory  | Description   |
2641| ---- | ------ | ---- | ----- |
2642| fd   | number | Yes   | FD of the file to close.|
2643
2644**Return value**
2645
2646| Type                 | Description        |
2647| ------------------- | ---------- |
2648| Promise&lt;void&gt; | Promise that returns no value.|
2649
2650**Error codes**
2651
2652For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2653
2654| ID| Error Message|
2655| -------- | ---------------------------------------- |
2656| 401       |  if parameter is invalid.         |
2657| 13900020     | Invalid argument.         |
2658| 14000011       | System inner fail.         |
2659
2660**Example**
2661
2662```ts
2663import dataSharePredicates from '@ohos.data.dataSharePredicates';
2664
2665async function example() {
2666  console.info('closeDemo');
2667  try {
2668    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2669    let fetchOption: photoAccessHelper.FetchOptions = {
2670      fetchColumns: [],
2671      predicates: predicates
2672    };
2673    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2674    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2675    let fd = await asset.open('rw');
2676    console.info('file fd', fd);
2677    await asset.close(fd);
2678    console.info('asset close succeed.');
2679  } catch (err) {
2680    console.error('close failed, message = ' + err);
2681  }
2682}
2683```
2684
2685### getThumbnail
2686
2687getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
2688
2689Obtains the thumbnail of this file. This API uses an asynchronous callback to return the result.
2690
2691**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2692
2693**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2694
2695**Parameters**
2696
2697| Name     | Type                                 | Mandatory  | Description              |
2698| -------- | ----------------------------------- | ---- | ---------------- |
2699| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked to return the PixelMap of the thumbnail.|
2700
2701**Error codes**
2702
2703For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2704
2705| ID| Error Message|
2706| -------- | ---------------------------------------- |
2707| 401       |  if parameter is invalid.         |
2708| 13900012     | Permission denied.         |
2709| 13900020     | Invalid argument.         |
2710| 14000011       | System inner fail.         |
2711
2712**Example**
2713
2714```ts
2715import dataSharePredicates from '@ohos.data.dataSharePredicates';
2716
2717async function example() {
2718  console.info('getThumbnailDemo');
2719  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2720  let fetchOption: photoAccessHelper.FetchOptions = {
2721    fetchColumns: [],
2722    predicates: predicates
2723  };
2724  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2725  let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2726  console.info('asset displayName = ', asset.displayName);
2727  asset.getThumbnail((err, pixelMap) => {
2728    if (err === undefined) {
2729      console.info('getThumbnail successful ' + pixelMap);
2730    } else {
2731      console.error('getThumbnail fail', err);
2732    }
2733  });
2734}
2735```
2736
2737### getThumbnail
2738
2739getThumbnail(size: image.Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
2740
2741Obtains the file thumbnail of the given size. This API uses an asynchronous callback to return the result.
2742
2743**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2744
2745**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2746
2747**Parameters**
2748
2749| Name     | Type                                 | Mandatory  | Description              |
2750| -------- | ----------------------------------- | ---- | ---------------- |
2751| size     | [image.Size](js-apis-image.md#size) | Yes   | Size of the thumbnail.           |
2752| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked to return the PixelMap of the thumbnail.|
2753
2754**Error codes**
2755
2756For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2757
2758| ID| Error Message|
2759| -------- | ---------------------------------------- |
2760| 401       |  if parameter is invalid.         |
2761| 13900012     | Permission denied.         |
2762| 13900020     | Invalid argument.         |
2763| 14000011       | System inner fail.         |
2764
2765**Example**
2766
2767```ts
2768import dataSharePredicates from '@ohos.data.dataSharePredicates';
2769import image from '@ohos.multimedia.image'
2770
2771async function example() {
2772  console.info('getThumbnailDemo');
2773  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2774  let fetchOption: photoAccessHelper.FetchOptions = {
2775    fetchColumns: [],
2776    predicates: predicates
2777  };
2778  let size: image.Size = { width: 720, height: 720 };
2779  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2780  let asset = await fetchResult.getFirstObject();
2781  console.info('asset displayName = ', asset.displayName);
2782  asset.getThumbnail(size, (err, pixelMap) => {
2783    if (err === undefined) {
2784      console.info('getThumbnail successful ' + pixelMap);
2785    } else {
2786      console.error('getThumbnail fail', err);
2787    }
2788  });
2789}
2790```
2791
2792### getThumbnail
2793
2794getThumbnail(size?: image.Size): Promise&lt;image.PixelMap&gt;
2795
2796Obtains the file thumbnail of the given size. This API uses a promise to return the result.
2797
2798**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2799
2800**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2801
2802**Parameters**
2803
2804| Name | Type            | Mandatory  | Description   |
2805| ---- | -------------- | ---- | ----- |
2806| size | [image.Size](js-apis-image.md#size) | No   | Size of the thumbnail.|
2807
2808**Return value**
2809
2810| Type                           | Description                   |
2811| ----------------------------- | --------------------- |
2812| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise used to return the PixelMap of the thumbnail.|
2813
2814**Error codes**
2815
2816For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2817
2818| ID| Error Message|
2819| -------- | ---------------------------------------- |
2820| 401       |  if parameter is invalid.         |
2821| 13900012     | Permission denied.         |
2822| 13900020     | Invalid argument.         |
2823| 14000011       | System inner fail.         |
2824
2825**Example**
2826
2827```ts
2828import dataSharePredicates from '@ohos.data.dataSharePredicates';
2829import image from '@ohos.multimedia.image'
2830import { BusinessError } from '@ohos.base';
2831
2832async function example() {
2833  console.info('getThumbnailDemo');
2834  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2835  let fetchOption: photoAccessHelper.FetchOptions = {
2836    fetchColumns: [],
2837    predicates: predicates
2838  };
2839  let size: image.Size = { width: 720, height: 720 };
2840  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2841  let asset = await fetchResult.getFirstObject();
2842  console.info('asset displayName = ', asset.displayName);
2843  asset.getThumbnail(size).then((pixelMap) => {
2844    console.info('getThumbnail successful ' + pixelMap);
2845  }).catch((err: BusinessError) => {
2846    console.error('getThumbnail fail' + err);
2847  });
2848}
2849```
2850
2851### setFavorite<sup>(deprecated)</sup>
2852
2853setFavorite(favoriteState: boolean, callback: AsyncCallback&lt;void&gt;): void
2854
2855Favorites or unfavorites this file. This API uses an asynchronous callback to return the result.
2856
2857> **NOTE**
2858>
2859> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setFavorite](#setfavorite11) instead.
2860
2861**System API**: This is a system API.
2862
2863**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2864
2865**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2866
2867**Parameters**
2868
2869| Name       | Type                       | Mandatory  | Description                                |
2870| ---------- | ------------------------- | ---- | ---------------------------------- |
2871| favoriteState | boolean                   | Yes   | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
2872| callback   | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.                             |
2873
2874**Error codes**
2875
2876For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2877
2878| ID| Error Message|
2879| -------- | ---------------------------------------- |
2880| 202        |  Called by non-system application.         |
2881| 401       |  if parameter is invalid.         |
2882| 13900012     | Permission denied.         |
2883| 13900020     | Invalid argument.         |
2884| 14000011       | System inner fail.         |
2885
2886**Example**
2887
2888```ts
2889import dataSharePredicates from '@ohos.data.dataSharePredicates';
2890
2891async function example() {
2892  console.info('setFavoriteDemo');
2893  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2894  let fetchOption: photoAccessHelper.FetchOptions = {
2895    fetchColumns: [],
2896    predicates: predicates
2897  };
2898  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2899  let asset = await fetchResult.getFirstObject();
2900  asset.setFavorite(true, (err) => {
2901    if (err === undefined) {
2902      console.info('favorite successfully');
2903    } else {
2904      console.error('favorite failed with error:' + err);
2905    }
2906  });
2907}
2908```
2909
2910### setFavorite<sup>(deprecated)</sup>
2911
2912setFavorite(favoriteState: boolean): Promise&lt;void&gt;
2913
2914Favorites or unfavorites this file asset. This API uses a promise to return the result.
2915
2916> **NOTE**
2917>
2918> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setFavorite](#setfavorite11) instead.
2919
2920**System API**: This is a system API.
2921
2922**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2923
2924**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2925
2926**Parameters**
2927
2928| Name       | Type     | Mandatory  | Description                                |
2929| ---------- | ------- | ---- | ---------------------------------- |
2930| favoriteState | boolean | Yes   | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
2931
2932**Return value**
2933
2934| Type                 | Description        |
2935| ------------------- | ---------- |
2936| Promise&lt;void&gt; | Promise that returns no value.|
2937
2938**Error codes**
2939
2940For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
2941
2942| ID| Error Message|
2943| -------- | ---------------------------------------- |
2944| 202        |  Called by non-system application.         |
2945| 401       |  if parameter is invalid.         |
2946| 13900012     | Permission denied.         |
2947| 13900020     | Invalid argument.         |
2948| 14000011       | System inner fail.         |
2949
2950**Example**
2951
2952```ts
2953import dataSharePredicates from '@ohos.data.dataSharePredicates';
2954import { BusinessError } from '@ohos.base';
2955
2956async function example() {
2957  console.info('setFavoriteDemo');
2958  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2959  let fetchOption: photoAccessHelper.FetchOptions = {
2960    fetchColumns: [],
2961    predicates: predicates
2962  };
2963  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2964  let asset = await fetchResult.getFirstObject();
2965  asset.setFavorite(true).then(() => {
2966    console.info('setFavorite successfully');
2967  }).catch((err: BusinessError) => {
2968    console.error('setFavorite failed with error:' + err);
2969  });
2970}
2971```
2972
2973### setHidden<sup>(deprecated)</sup>
2974
2975setHidden(hiddenState: boolean, callback: AsyncCallback&lt;void&gt;): void
2976
2977Sets this file to hidden state. This API uses an asynchronous callback to return the result.
2978
2979Private files are stored in the private album. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album.
2980
2981> **NOTE**
2982>
2983> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setHidden](#sethidden11) instead.
2984
2985**System API**: This is a system API.
2986
2987**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2988
2989**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2990
2991**Parameters**
2992
2993| Name       | Type                       | Mandatory  | Description                                |
2994| ---------- | ------------------------- | ---- | ---------------------------------- |
2995| hiddenState | boolean                   | Yes   | Whether to set a file to hidden state. The value **true** means to hide the file; the value **false** means the opposite.|
2996| callback   | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.                             |
2997
2998**Error codes**
2999
3000For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3001
3002| ID| Error Message|
3003| -------- | ---------------------------------------- |
3004| 202        |  Called by non-system application.         |
3005| 401       |  if parameter is invalid.         |
3006| 13900012     | Permission denied.         |
3007| 13900020     | Invalid argument.         |
3008| 14000011       | System inner fail.         |
3009
3010**Example**
3011
3012```ts
3013import dataSharePredicates from '@ohos.data.dataSharePredicates';
3014
3015async function example() {
3016  console.info('setHiddenDemo');
3017  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3018  let fetchOption: photoAccessHelper.FetchOptions = {
3019    fetchColumns: [],
3020    predicates: predicates
3021  };
3022  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3023  let asset = await fetchResult.getFirstObject();
3024  asset.setHidden(true, (err) => {
3025    if (err === undefined) {
3026      console.info('setHidden successfully');
3027    } else {
3028      console.error('setHidden failed with error:' + err);
3029    }
3030  });
3031}
3032```
3033
3034### setHidden<sup>(deprecated)</sup>
3035
3036setHidden(hiddenState: boolean): Promise&lt;void&gt;
3037
3038Sets this file asset to hidden state. This API uses a promise to return the result.
3039
3040Private files are stored in the private album. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album.
3041
3042> **NOTE**
3043>
3044> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setHidden](#sethidden11) instead.
3045
3046**System API**: This is a system API.
3047
3048**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3049
3050**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3051
3052**Parameters**
3053
3054| Name       | Type     | Mandatory  | Description                                |
3055| ---------- | ------- | ---- | ---------------------------------- |
3056| hiddenState | boolean | Yes   | Whether to set a file to hidden state. The value **true** means to hide the file; the value **false** means the opposite.|
3057
3058**Return value**
3059
3060| Type                 | Description        |
3061| ------------------- | ---------- |
3062| Promise&lt;void&gt; | Promise that returns no value.|
3063
3064**Error codes**
3065
3066For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3067
3068| ID| Error Message|
3069| -------- | ---------------------------------------- |
3070| 202        |  Called by non-system application.         |
3071| 401       |  if parameter is invalid.         |
3072| 13900012     | Permission denied.         |
3073| 13900020     | Invalid argument.         |
3074| 14000011       | System inner fail.         |
3075
3076**Example**
3077
3078```ts
3079import dataSharePredicates from '@ohos.data.dataSharePredicates';
3080import { BusinessError } from '@ohos.base';
3081
3082async function example() {
3083  // Restore a file from a hidden album. Before the operation, ensure that the file exists in the hidden album.
3084  console.info('setHiddenDemo');
3085  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3086  let fetchOption: photoAccessHelper.FetchOptions = {
3087    fetchColumns: [],
3088    predicates: predicates
3089  };
3090  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.HIDDEN);
3091  let album = await albumList.getFirstObject();
3092  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3093  let asset = await fetchResult.getFirstObject();
3094  asset.setHidden(false).then(() => {
3095    console.info('setHidden successfully');
3096  }).catch((err: BusinessError) => {
3097    console.error('setHidden failed with error:' + err);
3098  });
3099}
3100```
3101
3102### getExif
3103
3104getExif(): Promise&lt;string&gt;
3105
3106Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses a promise to return the result.
3107
3108The EXIF tag information is provided by the [image](js-apis-image.md) module. For details about the EXIF tag information, see [image.PropertyKey](js-apis-image.md#propertykey7).
3109
3110> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [PhotoKeys.USER_COMMENT](#photokeys). These two fields must be passed in via **fetchColumns**.
3111
3112**System API**: This is a system API.
3113
3114**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3115
3116**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3117
3118**Return value**
3119
3120| Type                                   | Description             |
3121| --------------------------------------- | ----------------- |
3122| Promise&lt;string&gt; | Callback invoked to return the JSON string obtained.|
3123
3124**Error codes**
3125
3126For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3127
3128| ID| Error Message|
3129| -------- | ---------------------------------------- |
3130| 202        |  Called by non-system application.         |
3131| 401       |  if parameter is invalid.         |
3132| 13900012     | Permission denied.         |
3133| 13900020     | Invalid argument.         |
3134| 14000011       | System inner fail.         |
3135
3136**Example**
3137
3138```ts
3139import dataSharePredicates from '@ohos.data.dataSharePredicates';
3140
3141async function example() {
3142  try {
3143    console.info('getExifDemo');
3144    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3145    let fetchOptions: photoAccessHelper.FetchOptions = {
3146      fetchColumns: [ 'all_exif',  photoAccessHelper.PhotoKeys.USER_COMMENT],
3147      predicates: predicates
3148    };
3149    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3150    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3151    let exifMessage = await photoAsset.getExif();
3152    let userCommentKey = 'UserComment';
3153    let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
3154    console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
3155    fetchResult.close();
3156  } catch (err) {
3157    console.error('getExifDemoCallback failed with error: ' + err);
3158  }
3159}
3160```
3161
3162### getExif
3163
3164getExif(callback: AsyncCallback&lt;string&gt;): void
3165
3166Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses an asynchronous callback to return the result.
3167
3168The EXIF tag information is provided by the [image](js-apis-image.md) module. For details about the EXIF tag information, see [image.PropertyKey](js-apis-image.md#propertykey7).
3169
3170> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [PhotoKeys.USER_COMMENT](#photokeys). These two fields must be passed in via **fetchColumns**.
3171
3172**System API**: This is a system API.
3173
3174**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3175
3176**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3177
3178**Parameters**
3179
3180| Name  | Type                     | Mandatory| Description      |
3181| -------- | ------------------------- | ---- | ---------- |
3182| callback | AsyncCallback&lt;string&gt; | Yes  | Callback invoked to return the JSON string obtained.|
3183
3184**Error codes**
3185
3186For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3187
3188| ID| Error Message|
3189| -------- | ---------------------------------------- |
3190| 202        |  Called by non-system application.         |
3191| 401       |  if parameter is invalid.         |
3192| 13900012     | Permission denied.         |
3193| 13900020     | Invalid argument.         |
3194| 14000011       | System inner fail.         |
3195
3196**Example**
3197
3198```ts
3199import dataSharePredicates from '@ohos.data.dataSharePredicates';
3200
3201async function example() {
3202  try {
3203    console.info('getExifDemo');
3204    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3205    predicates.isNotNull('all_exif')
3206    let fetchOptions: photoAccessHelper.FetchOptions = {
3207      fetchColumns: ['all_exif', photoAccessHelper.PhotoKeys.USER_COMMENT],
3208      predicates: predicates
3209    };
3210    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3211    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3212    console.info('getExifDemo photoAsset displayName: ' + JSON.stringify(photoAsset.displayName));
3213    let userCommentKey = 'UserComment';
3214    photoAsset.getExif((err, exifMessage) => {
3215      if (exifMessage !== undefined) {
3216        let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
3217        console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
3218      } else {
3219        console.error('getExif failed, message = ', err);
3220      }
3221    });
3222    fetchResult.close();
3223  } catch (err) {
3224    console.error('getExifDemoCallback failed with error: ' + err);
3225  }
3226}
3227```
3228
3229### setUserComment<sup>(deprecated)</sup>
3230
3231setUserComment(userComment: string): Promise&lt;void&gt;
3232
3233Sets user comment information of an image or video. This API uses a promise to return the result.
3234
3235> **NOTE**
3236>
3237> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setUserComment](#setusercomment11) instead.
3238
3239> **NOTE**<br>This API can be used to modify the comment information of only images or videos.
3240
3241**System API**: This is a system API.
3242
3243**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3244
3245**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3246
3247**Parameters**
3248
3249| Name  | Type                     | Mandatory| Description      |
3250| -------- | ------------------------- | ---- | ---------- |
3251| userComment | string | Yes  | User comment information to set, which cannot exceed 420 characters.|
3252
3253**Return value**
3254
3255| Type                                   | Description             |
3256| --------------------------------------- | ----------------- |
3257|Promise&lt;void&gt; | Promise that returns no value.|
3258
3259**Error codes**
3260
3261For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3262
3263| ID| Error Message|
3264| -------- | ---------------------------------------- |
3265| 202        |  Called by non-system application.         |
3266| 401       |  if parameter is invalid.         |
3267| 13900012     | Permission denied.         |
3268| 13900020     | Invalid argument.         |
3269| 14000011       | System inner fail.         |
3270
3271**Example**
3272
3273```ts
3274import dataSharePredicates from '@ohos.data.dataSharePredicates';
3275
3276async function example() {
3277  try {
3278    console.info('setUserCommentDemo')
3279    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3280    let fetchOptions: photoAccessHelper.FetchOptions = {
3281      fetchColumns: [],
3282      predicates: predicates
3283    };
3284    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3285    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3286    let userComment = 'test_set_user_comment';
3287    await photoAsset.setUserComment(userComment);
3288  } catch (err) {
3289    console.error('setUserCommentDemoPromise failed with error: ' + err);
3290  }
3291}
3292```
3293
3294### setUserComment<sup>(deprecated)</sup>
3295
3296setUserComment(userComment: string, callback: AsyncCallback&lt;void&gt;): void
3297
3298Sets user comment information of an image or video. This API uses an asynchronous callback to return the result.
3299
3300> **NOTE**
3301>
3302> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setUserComment](#setusercomment11) instead.
3303
3304> **NOTE**<br>This API can be used to modify the comment information of only images or videos.
3305
3306**System API**: This is a system API.
3307
3308**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3309
3310**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3311
3312**Parameters**
3313
3314| Name  | Type                     | Mandatory| Description      |
3315| -------- | ------------------------- | ---- | ---------- |
3316| userComment | string | Yes  | User comment information to set, which cannot exceed 420 characters.|
3317| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3318
3319**Error codes**
3320
3321For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3322
3323| ID| Error Message|
3324| -------- | ---------------------------------------- |
3325| 202        |  Called by non-system application.         |
3326| 401       |  if parameter is invalid.         |
3327| 13900012     | Permission denied.         |
3328| 13900020     | Invalid argument.         |
3329| 14000011       | System inner fail.         |
3330
3331**Example**
3332
3333```ts
3334import dataSharePredicates from '@ohos.data.dataSharePredicates';
3335
3336async function example() {
3337  try {
3338    console.info('setUserCommentDemo')
3339    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3340    let fetchOptions: photoAccessHelper.FetchOptions = {
3341      fetchColumns: [],
3342      predicates: predicates
3343    };
3344    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3345    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3346    let userComment = 'test_set_user_comment';
3347    photoAsset.setUserComment(userComment, (err) => {
3348      if (err === undefined) {
3349        console.info('setUserComment successfully');
3350      } else {
3351        console.error('setUserComment failed with error: ' + err);
3352      }
3353    });
3354  } catch (err) {
3355    console.error('setUserCommentDemoCallback failed with error: ' + err);
3356  }
3357}
3358```
3359
3360### setPending<sup>11+</sup>
3361
3362setPending(pendingState: boolean, callback: AsyncCallback&lt;void&gt;): void
3363
3364Sets the pending state for this image or video asset. This API uses an asynchronous callback to return the result.
3365
3366The pending state can be removed only through **setPending(false)**. You can use **photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)** to check whether the asset state is pending. If the asset is in pending state, **true** is returned. Otherwise, **false** is returned.
3367
3368> **NOTE**<br>**setPending** can be used only during the file creation process. Once the FD is closed, **setPending(true)** cannot be used to set the pending state for the file.
3369
3370**System API**: This is a system API.
3371
3372**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3373
3374**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3375
3376**Parameters**
3377
3378| Name       | Type     | Mandatory  | Description                                |
3379| ---------- | ------- | ---- | ---------------------------------- |
3380| pendingState | boolean | Yes   | Whether to set the file to pending state. The value **true** means to set the file to pending state, and the value **false** means to remove the pending state.|
3381| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
3382
3383**Error codes**
3384
3385For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3386
3387| ID| Error Message|
3388| -------- | ---------------------------------------- |
3389| 201   | Permission denied.        |
3390| 202   | Called by non-system application.         |
3391| 401   | if parameter is invalid.         |
3392| 14000011   | System inner fail.        |
3393
3394**Example**
3395
3396```ts
3397async function example() {
3398  try {
3399    console.info('setPendingCallbackDemo');
3400    let testFileName: string = 'testFile' + Date.now() + '.jpg';
3401    let photoAsset = await phAccessHelper.createAsset(testFileName);
3402    let fd = await photoAsset.open('rw');
3403    photoAsset.setPending(true, async (err) => {
3404      if (err !== undefined) {
3405        console.error('setPending(true) failed with error: ' + err);
3406        return;
3407      }
3408      // write photo buffer in fd
3409      photoAsset.setPending(false, async (err) => {
3410        if (err !== undefined) {
3411          console.error('setPending(false) failed with error: ' + err);
3412          return;
3413        }
3414        await photoAsset.close(fd);
3415      });
3416    });
3417  } catch (err) {
3418    console.error('setPendingCallbackDemo failed with error: ' + err);
3419  }
3420}
3421```
3422
3423### setPending<sup>11+</sup>
3424
3425setPending(pendingState: boolean): Promise&lt;void&gt;
3426
3427Sets the pending state for this image or video asset. This API uses a promise to return the result.
3428
3429The pending state can be removed only through **setPending(false)**. You can use **photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)** to check whether the asset state is pending. If the asset is in pending state, **true** is returned. Otherwise, **false** is returned.
3430
3431> **NOTE**<br>**setPending** can be used only during the file creation process. Once the FD is closed, **setPending(true)** cannot be used to set the pending state for the file.
3432
3433**System API**: This is a system API.
3434
3435**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3436
3437**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3438
3439**Parameters**
3440
3441| Name       | Type     | Mandatory  | Description                                |
3442| ---------- | ------- | ---- | ---------------------------------- |
3443| pendingState | boolean | Yes   | Whether to set the file to pending state. The value **true** means to set the file to pending state, and the value **false** means to remove the pending state.|
3444
3445**Return value**
3446
3447| Type                                   | Description             |
3448| --------------------------------------- | ----------------- |
3449|Promise&lt;boolean&gt; | Promise that returns no value.|
3450
3451**Error codes**
3452
3453For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3454
3455| ID| Error Message|
3456| -------- | ---------------------------------------- |
3457| 201   | Permission denied.        |
3458| 202   | Called by non-system application.         |
3459| 401   | if parameter is invalid.         |
3460| 14000011   | System inner fail.        |
3461
3462**Example**
3463
3464```ts
3465async function example() {
3466  try {
3467    console.info('setPendingPromiseDemo');
3468    let testFileName: string = 'testFile' + Date.now() + '.jpg';
3469    let photoAsset = await phAccessHelper.createAsset(testFileName);
3470    let fd = await photoAsset.open('rw');
3471    await photoAsset.setPending(true);
3472    // write photo buffer in fd
3473    photoAsset.setPending(false);
3474    await photoAsset.close(fd);
3475  } catch (err) {
3476    console.error('setPendingPromiseDemo failed with error: ' + err);
3477  }
3478}
3479```
3480
3481### isEdited<sup>11+</sup>
3482
3483isEdited(callback: AsyncCallback&lt;boolean&gt;): void
3484
3485Checks whether this image or video asset is edited. This API uses an asynchronous callback to return the result.
3486
3487**System API**: This is a system API.
3488
3489**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3490
3491**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3492
3493**Parameters**
3494
3495| Name       | Type     | Mandatory  | Description                                |
3496| ---------- | ------- | ---- | ---------------------------------- |
3497| callback | AsyncCallback&lt;boolean&gt; | Yes   | Callback invoked to return the result.|
3498
3499**Error codes**
3500
3501For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3502
3503| ID| Error Message|
3504| -------- | ---------------------------------------- |
3505| 201   | Permission denied.        |
3506| 202   | Called by non-system application.         |
3507| 401   | if parameter is invalid.         |
3508| 14000011   | System inner fail.        |
3509
3510**Example**
3511
3512```ts
3513import dataSharePredicates from '@ohos.data.dataSharePredicates';
3514
3515async function example() {
3516  try {
3517    console.info('isEditedCallbackDemo')
3518    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3519    let fetchOptions: photoAccessHelper.FetchOptions = {
3520      fetchColumns: [],
3521      predicates: predicates
3522    };
3523    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3524    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3525    photoAsset.isEdited((err, isEdited) => {
3526      if (err === undefined) {
3527        if (isEdited === true) {
3528          console.info('Photo is edited');
3529        } else {
3530          console.info('Photo is not edited');
3531        }
3532      } else {
3533        console.error('isEdited failed with error: ' + err);
3534      }
3535    });
3536  } catch (err) {
3537    console.error('isEditedDemoCallback failed with error: ' + err);
3538  }
3539}
3540```
3541
3542### isEdited<sup>11+</sup>
3543
3544isEdited(): Promise&lt;boolean&gt;
3545
3546Checks whether this image or video asset is edited. This API uses a promise to return the result.
3547
3548**System API**: This is a system API.
3549
3550**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3551
3552**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3553
3554**Return value**
3555
3556| Type                                   | Description             |
3557| --------------------------------------- | ----------------- |
3558|Promise&lt;boolean&gt; | Promise used to return the result.|
3559
3560
3561**Error codes**
3562
3563For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3564
3565| ID| Error Message|
3566| -------- | ---------------------------------------- |
3567| 201   | Permission denied.        |
3568| 202   | Called by non-system application.         |
3569| 401   | if parameter is invalid.         |
3570| 14000011   | System inner fail.        |
3571
3572**Example**
3573
3574```ts
3575import dataSharePredicates from '@ohos.data.dataSharePredicates';
3576
3577async function example() {
3578  try {
3579    console.info('isEditedPromiseDemo')
3580    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3581    let fetchOptions: photoAccessHelper.FetchOptions = {
3582      fetchColumns: [],
3583      predicates: predicates
3584    };
3585    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3586    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3587    let isEdited = await photoAsset.isEdited();
3588    if (isEdited === true) {
3589      console.info('Photo is edited');
3590    } else {
3591      console.info('Photo is not edited');
3592    }
3593  } catch (err) {
3594    console.error('isEditedDemoCallback failed with error: ' + err);
3595  }
3596}
3597```
3598
3599### requestEditData<sup>11+</sup>
3600
3601requestEditData(callback: AsyncCallback&lt;string&gt;): void
3602
3603Obtains the edit data of this image or video asset. This API uses an asynchronous callback to return the result.
3604
3605If the asset has never been edited, an empty string is returned.
3606
3607**System API**: This is a system API.
3608
3609**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3610
3611**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3612
3613**Parameters**
3614
3615| Name       | Type     | Mandatory  | Description                                |
3616| ---------- | ------- | ---- | ---------------------------------- |
3617| callback | AsyncCallback&lt;string&gt; | Yes   | Callback invoked to return the edit data obtained.|
3618
3619**Error codes**
3620
3621For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3622
3623| ID| Error Message|
3624| -------- | ---------------------------------------- |
3625| 201   | Permission denied.        |
3626| 202   | Called by non-system application.         |
3627| 401   | if parameter is invalid.         |
3628| 14000011   | System inner fail.        |
3629
3630**Example**
3631
3632```ts
3633import dataSharePredicates from '@ohos.data.dataSharePredicates';
3634
3635async function example() {
3636  try {
3637    console.info('requestEditDataCallbackDemo')
3638    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3639    let fetchOptions: photoAccessHelper.FetchOptions = {
3640      fetchColumns: [],
3641      predicates: predicates
3642    };
3643    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3644    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3645    photoAsset.requestEditData((err, editdata) => {
3646      if (err === undefined) {
3647        console.info('Editdata is ' + editdata);
3648      } else {
3649        console.error('requestEditData failed with error: ' + err);
3650      }
3651    });
3652  } catch (err) {
3653    console.error('requestEditDataCallbackDemo failed with error: ' + err);
3654  }
3655}
3656```
3657
3658### requestEditData<sup>11+</sup>
3659
3660requestEditData(): Promise&lt;string&gt;
3661
3662Obtains the edit data of this image or video asset. This API uses a promise to return the result.
3663
3664If the asset has never been edited, an empty string is returned.
3665
3666**System API**: This is a system API.
3667
3668**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3669
3670**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3671
3672**Return value**
3673
3674| Type                                   | Description             |
3675| --------------------------------------- | ----------------- |
3676|Promise&lt;string&gt; | Promise used to return the edit data obtained.|
3677
3678
3679**Error codes**
3680
3681For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3682
3683| ID| Error Message|
3684| -------- | ---------------------------------------- |
3685| 201   | Permission denied.        |
3686| 202   | Called by non-system application.         |
3687| 401   | if parameter is invalid.         |
3688| 14000011   | System inner fail.        |
3689
3690**Example**
3691
3692```ts
3693import dataSharePredicates from '@ohos.data.dataSharePredicates';
3694
3695async function example() {
3696  try {
3697    console.info('requestEditDataPromiseDemo')
3698    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3699    let fetchOptions: photoAccessHelper.FetchOptions = {
3700      fetchColumns: [],
3701      predicates: predicates
3702    };
3703    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3704    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3705    let editdata: string = await photoAsset.requestEditData();
3706    console.info('Editdata is ' + editdata);
3707  } catch (err) {
3708    console.error('requestEditDataPromiseDemo failed with error: ' + err);
3709  }
3710}
3711```
3712
3713### getEditData<sup>11+</sup>
3714
3715getEditData(): Promise&lt;MediaAssetEditData&gt;
3716
3717Obtains the edited data of this asset. This API uses a promise to return the result.
3718
3719If the asset has not been edited, an empty string is returned.
3720
3721**System API**: This is a system API.
3722
3723**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3724
3725**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3726
3727**Return value**
3728
3729| Type                                   | Description             |
3730| --------------------------------------- | ----------------- |
3731|Promise&lt;[MediaAssetEditData](#mediaasseteditdata11)&gt; | Promise used to return the edited asset data.|
3732
3733**Error codes**
3734
3735For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3736
3737| ID| Error Message|
3738| -------- | ---------------------------------------- |
3739| 201   | Permission denied.        |
3740| 202   | Called by non-system application.         |
3741| 401   | if parameter is invalid.         |
3742| 14000011   | System inner fail.        |
3743
3744**Example**
3745
3746```ts
3747import dataSharePredicates from '@ohos.data.dataSharePredicates';
3748
3749async function example() {
3750  try {
3751    console.info('getEditDataDemo')
3752    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3753    let fetchOptions: photoAccessHelper.FetchOptions = {
3754      fetchColumns: [],
3755      predicates: predicates
3756    };
3757    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3758    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3759    let assetEditData: photoAccessHelper.MediaAssetEditData = await photoAsset.getEditData();
3760    let data: string = assetEditData.data;
3761    console.info('edit data is ' + data);
3762  } catch (err) {
3763    console.error('getEditDataDemo failed with error: ' + err);
3764  }
3765}
3766```
3767
3768### requestSource<sup>11+</sup>
3769
3770requestSource(callback: AsyncCallback&lt;number&gt;): void
3771
3772Opens the source file to obtain the FD. This API uses an asynchronous callback to return the result.
3773
3774**System API**: This is a system API.
3775
3776**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3777
3778**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3779
3780**Parameters**
3781
3782| Name       | Type     | Mandatory  | Description                                |
3783| ---------- | ------- | ---- | ---------------------------------- |
3784| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the FD.|
3785
3786**Error codes**
3787
3788For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3789
3790| ID| Error Message|
3791| -------- | ---------------------------------------- |
3792| 201   | Permission denied.        |
3793| 202   | Called by non-system application.         |
3794| 401   | if parameter is invalid.         |
3795| 14000011   | System inner fail.        |
3796
3797**Example**
3798
3799```ts
3800import dataSharePredicates from '@ohos.data.dataSharePredicates';
3801
3802async function example() {
3803  try {
3804    console.info('requsetSourceCallbackDemo')
3805    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3806    let fetchOptions: photoAccessHelper.FetchOptions = {
3807      fetchColumns: [],
3808      predicates: predicates
3809    };
3810    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3811    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3812    photoAsset.requestSource((err, fd) => {
3813      if (err === undefined) {
3814        console.info('Source fd is ' + fd);
3815      } else {
3816        console.error('requestSource failed with error: ' + err);
3817      }
3818    });
3819  } catch (err) {
3820    console.error('requsetSourceCallbackDemo failed with error: ' + err);
3821  }
3822}
3823```
3824
3825### requestSource<sup>11+</sup>
3826
3827requestSource(): Promise&lt;number&gt;
3828
3829Opens the source file to obtain the FD. This API uses a promise to return the result.
3830
3831**System API**: This is a system API.
3832
3833**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3834
3835**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3836
3837**Return value**
3838
3839| Type                                   | Description             |
3840| --------------------------------------- | ----------------- |
3841|Promise&lt;number&gt; | Promise used to return the FD.|
3842
3843**Error codes**
3844
3845For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3846
3847| ID| Error Message|
3848| -------- | ---------------------------------------- |
3849| 201   | Permission denied.        |
3850| 202   | Called by non-system application.         |
3851| 401   | if parameter is invalid.         |
3852| 14000011   | System inner fail.        |
3853
3854**Example**
3855
3856```ts
3857import dataSharePredicates from '@ohos.data.dataSharePredicates';
3858
3859async function example() {
3860  try {
3861    console.info('requsetSourcePromiseDemo')
3862    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3863    let fetchOptions: photoAccessHelper.FetchOptions = {
3864      fetchColumns: [],
3865      predicates: predicates
3866    };
3867    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3868    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3869    let fd = await photoAsset.requestSource();
3870    console.info('Source fd is ' + fd);
3871  } catch (err) {
3872    console.error('requsetSourcePromiseDemo failed with error: ' + err);
3873  }
3874}
3875```
3876
3877### commitEditedAsset<sup>11+</sup>
3878
3879commitEditedAsset(editData: string, uri: string, callback: AsyncCallback&lt;void&gt;)
3880
3881Commits the edited image or video asset. This API uses an asynchronous callback to return the result.
3882
3883The edited file is saved to the media library based on the URI. The URI is **FileUri** of the edited file in the application sandbox directory. For details, see [FileUri](js-apis-file-fileuri.md).
3884
3885> **NOTE**<br>The commit operation overwrites the previous edited data.
3886
3887**System API**: This is a system API.
3888
3889**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3890
3891**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3892
3893**Parameters**
3894
3895| Name       | Type     | Mandatory  | Description                                |
3896| ---------- | ------- | ---- | ---------------------------------- |
3897| editData | string | Yes   | New data to commit.|
3898| uri | string | Yes   | URI of the committed image or video in the application sandbox.|
3899| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
3900
3901**Error codes**
3902
3903For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3904
3905| ID| Error Message|
3906| -------- | ---------------------------------------- |
3907| 201   | Permission denied.        |
3908| 202   | Called by non-system application.         |
3909| 401   | if parameter is invalid.         |
3910| 14000011   | System inner fail.        |
3911
3912**Example**
3913
3914```ts
3915import dataSharePredicates from '@ohos.data.dataSharePredicates';
3916
3917async function example() {
3918  try {
3919    console.info('commitEditedAssetCallbackDemo')
3920    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3921    let fetchOptions: photoAccessHelper.FetchOptions = {
3922      fetchColumns: [],
3923      predicates: predicates
3924    };
3925    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3926    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3927    let editData = '123456';
3928    let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3929    photoAsset.commitEditedAsset(editData, uri, (err) => {
3930      if (err === undefined) {
3931        console.info('commitEditedAsset is successful');
3932      } else {
3933        console.error('commitEditedAsset failed with error: ' + err);
3934      }
3935    });
3936  } catch (err) {
3937    console.error('commitEditedAssetCallbackDemo failed with error: ' + err);
3938  }
3939}
3940```
3941
3942### commitEditedAsset<sup>11+</sup>
3943
3944commitEditedAsset(editData: string, uri: string): Promise&lt;void&gt;
3945
3946Commits the edited image or video asset. This API uses a promise to return the result.
3947
3948The edited file is saved to the media library based on the URI. The URI is **FileUri** of the edited file in the application sandbox directory. For details, see [FileUri](js-apis-file-fileuri.md).
3949
3950> **NOTE**<br>The commit operation overwrites the previous edited data.
3951
3952**System API**: This is a system API.
3953
3954**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3955
3956**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3957
3958**Parameters**
3959
3960| Name       | Type     | Mandatory  | Description                                |
3961| ---------- | ------- | ---- | ---------------------------------- |
3962| editData | string | Yes   | New data to commit.|
3963| uri | string | Yes   | URI of the committed image or video in the application sandbox.|
3964
3965**Return value**
3966
3967| Type                                   | Description             |
3968| --------------------------------------- | ----------------- |
3969|Promise&lt;void&gt; | Promise that returns no value.|
3970
3971**Error codes**
3972
3973For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3974
3975| ID| Error Message|
3976| -------- | ---------------------------------------- |
3977| 201   | Permission denied.        |
3978| 202   | Called by non-system application.         |
3979| 401   | if parameter is invalid.         |
3980| 14000011   | System inner fail.        |
3981
3982**Example**
3983
3984```ts
3985import dataSharePredicates from '@ohos.data.dataSharePredicates';
3986
3987async function example() {
3988  try {
3989    console.info('commitEditedAssetPromiseDemo')
3990    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3991    let fetchOptions: photoAccessHelper.FetchOptions = {
3992      fetchColumns: [],
3993      predicates: predicates
3994    };
3995    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3996    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3997    let editData = '123456';
3998    let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3999    await photoAsset.commitEditedAsset(editData, uri);
4000    console.info('commitEditedAsset is successful');
4001  } catch (err) {
4002    console.error('commitEditedAssetPromiseDemo failed with error: ' + err);
4003  }
4004}
4005```
4006
4007### revertToOriginal<sup>11+</sup>
4008
4009revertToOriginal(callback: AsyncCallback&lt;void&gt;)
4010
4011Reverts to the state of the file before being edited. This API uses an asynchronous callback to return the result.
4012
4013> **NOTE**<br>This API deletes the edited data and edited image or video asset, and the deleted data cannot be restored. Exercise caution when using this API.
4014
4015**System API**: This is a system API.
4016
4017**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
4018
4019**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4020
4021**Parameters**
4022
4023| Name       | Type     | Mandatory  | Description                                |
4024| ---------- | ------- | ---- | ---------------------------------- |
4025| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
4026
4027**Error codes**
4028
4029For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4030
4031| ID| Error Message|
4032| -------- | ---------------------------------------- |
4033| 201   | Permission denied.        |
4034| 202   | Called by non-system application.         |
4035| 401   | if parameter is invalid.         |
4036| 14000011   | System inner fail.        |
4037
4038**Example**
4039
4040```ts
4041import dataSharePredicates from '@ohos.data.dataSharePredicates';
4042
4043async function example() {
4044  try {
4045    console.info('revertToOriginalCallbackDemo')
4046    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4047    let fetchOptions: photoAccessHelper.FetchOptions = {
4048      fetchColumns: [],
4049      predicates: predicates
4050    };
4051    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4052    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4053    photoAsset.revertToOriginal((err) => {
4054      if (err === undefined) {
4055        console.info('revertToOriginal is successful');
4056      } else {
4057        console.error('revertToOriginal failed with error: ' + err);
4058      }
4059    });
4060  } catch (err) {
4061    console.error('revertToOriginalCallbackDemo failed with error: ' + err);
4062  }
4063}
4064```
4065
4066### revertToOriginal<sup>11+</sup>
4067
4068revertToOriginal(): Promise&lt;void&gt;
4069
4070Reverts to the state of the file before being edited. This API uses a promise to return the result.
4071
4072> **NOTE**<br>This API deletes the edited data and edited image or video asset, and the deleted data cannot be restored. Exercise caution when using this API.
4073
4074**System API**: This is a system API.
4075
4076**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
4077
4078**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4079
4080**Return value**
4081
4082| Type                                   | Description             |
4083| --------------------------------------- | ----------------- |
4084|Promise&lt;string&gt; | Promise that returns no value.|
4085
4086**Error codes**
4087
4088For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4089
4090| ID| Error Message|
4091| -------- | ---------------------------------------- |
4092| 201   | Permission denied.        |
4093| 202   | Called by non-system application.         |
4094| 401   | if parameter is invalid.         |
4095| 14000011   | System inner fail.        |
4096
4097**Example**
4098
4099```ts
4100import dataSharePredicates from '@ohos.data.dataSharePredicates';
4101
4102async function example() {
4103  try {
4104    console.info('revertToOriginalPromiseDemo')
4105    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4106    let fetchOptions: photoAccessHelper.FetchOptions = {
4107      fetchColumns: [],
4108      predicates: predicates
4109    };
4110    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4111    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4112    photoAsset.revertToOriginal();
4113    console.info('revertToOriginal is successful');
4114  } catch (err) {
4115    console.error('revertToOriginalPromiseDemo failed with error: ' + err);
4116  }
4117}
4118```
4119
4120### requestPhoto<sup>11+</sup>
4121
4122requestPhoto(callback: AsyncCallback&lt;image.PixelMap&gt;): string
4123
4124Obtains the quick thumbnail and quality thumbnail of this asset. This API uses an asynchronous callback to return the result.
4125
4126The size of a quick thumbnail is 128 x 128, and the size of a quality thumbnail is 256 x 256. After this API is called, the callback will be invoked twice to return a quick thumbnail and a quality thumbnail in sequence.
4127
4128**System API**: This is a system API.
4129
4130**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4131
4132**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4133
4134**Parameters**
4135
4136| Name       | Type     | Mandatory  | Description                                |
4137| ---------- | ------- | ---- | ---------------------------------- |
4138| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked twice to return the quick and common thumbnails obtained.|
4139
4140**Return value**
4141
4142| Type                                   | Description             |
4143| --------------------------------------- | ----------------- |
4144| string | ID of the task for obtaining thumbnails.|
4145
4146**Error codes**
4147
4148For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4149
4150| ID| Error Message|
4151| -------- | ---------------------------------------- |
4152| 201   | Permission denied.        |
4153| 202   | Called by non-system application.         |
4154| 401   | if parameter is invalid.         |
4155| 14000011   | System inner fail.        |
4156
4157**Example**
4158
4159```ts
4160import dataSharePredicates from '@ohos.data.dataSharePredicates';
4161
4162async function example() {
4163  try {
4164    console.info('requestPhotoDemo')
4165    let options: photoAccessHelper.FetchOptions = {
4166      fetchColumns: [],
4167      predicates: new dataSharePredicates.DataSharePredicates()
4168    }
4169    let fetchResult = await phAccessHelper.getAssets(options);
4170    let photoAsset = await fetchResult.getFirstObject();
4171    let taskId: string = photoAsset.requestPhoto(async (err, pixel: image.PixelMap) => {
4172      if (err === undefined) {
4173        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
4174      } else {
4175        console.error('requestSource failed with error: ' + err);
4176      }
4177    })
4178    console.info('requestSource taskId: ' + taskId)
4179  } catch (err) {
4180    console.error('requestPhotoDemo failed with error: ' + err)
4181  }
4182}
4183```
4184
4185### requestPhoto<sup>11+</sup>
4186
4187requestPhoto(options: RequestPhotoOptions, callback: AsyncCallback&lt;image.PixelMap&gt;): string
4188
4189Obtains the thumbnails of an asset based on the specified options. This API uses an asynchronous callback to return the result.
4190
4191**System API**: This is a system API.
4192
4193**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4194
4195**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4196
4197**Parameters**
4198
4199| Name       | Type     | Mandatory  | Description                                |
4200| ---------- | ------- | ---- | ---------------------------------- |
4201| options | [RequestPhotoOptions](#requestphotooptions11) | Yes   | Options for obtaining the asset thumbnail.|
4202| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked to return the thumbnails obtained. The callback may be invoked more than once, depending on **options**.|
4203
4204**Return value**
4205
4206| Type                                   | Description             |
4207| --------------------------------------- | ----------------- |
4208| string | ID of the task for obtaining thumbnails.|
4209
4210**Error codes**
4211
4212For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4213
4214| ID| Error Message|
4215| -------- | ---------------------------------------- |
4216| 201   | Permission denied.        |
4217| 202   | Called by non-system application.         |
4218| 401   | if parameter is invalid.         |
4219| 14000011   | System inner fail.        |
4220
4221**Example**
4222
4223```ts
4224import dataSharePredicates from '@ohos.data.dataSharePredicates';
4225
4226async function example() {
4227  try {
4228    console.info('requestPhotoDemo')
4229    let options: photoAccessHelper.FetchOptions = {
4230      fetchColumns: [],
4231      predicates: new dataSharePredicates.DataSharePredicates()
4232    }
4233    let fetchResult = await phAccessHelper.getAssets(options);
4234    let photoAsset = await fetchResult.getFirstObject();
4235    let taskId: string = photoAsset.requestPhoto({
4236      "size": {
4237        "width": 256,
4238        "height": 256
4239      },
4240      "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS
4241    }, async (err, pixel: image.PixelMap) => {
4242      if (err === undefined) {
4243        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
4244      } else {
4245        console.error('requestSource failed with error: ' + err);
4246      }
4247    })
4248    console.info('requestSource taskId: ' + taskId)
4249  } catch (err) {
4250    console.error('requestPhotoDemo failed with error: ' + err)
4251  }
4252}
4253```
4254
4255### cancelPhotoRequest<sup>11+</sup>
4256
4257cancelPhotoRequest(requestId: string): void
4258
4259Cancels a task for obtaining media thumbnails.
4260
4261**System API**: This is a system API.
4262
4263**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4264
4265**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4266
4267**Parameters**
4268
4269| Name       | Type     | Mandatory  | Description                                |
4270| ---------- | ------- | ---- | ---------------------------------- |
4271| requestId | string | Yes   | ID of the task to cancel.|
4272
4273**Error codes**
4274
4275For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4276
4277| ID| Error Message|
4278| -------- | ---------------------------------------- |
4279| 201   | Permission denied.        |
4280| 202   | Called by non-system application.         |
4281| 401   | if parameter is invalid.         |
4282| 14000011   | System inner fail.        |
4283
4284**Example**
4285
4286```ts
4287import dataSharePredicates from '@ohos.data.dataSharePredicates';
4288
4289async function example() {
4290  try {
4291    console.info('cancelPhotoRequestDemo')
4292    let options: photoAccessHelper.FetchOptions = {
4293      fetchColumns: [],
4294      predicates: new dataSharePredicates.DataSharePredicates()
4295    }
4296    let fetchResult = await phAccessHelper.getAssets(options);
4297    let photoAsset = await fetchResult.getFirstObject();
4298    let taskId: string = photoAsset.requestPhoto({
4299      "size": {
4300        "width": 256,
4301        "height": 256
4302      },
4303      "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS
4304    }, async (err, pixel: image.PixelMap) => {
4305      if (err === undefined) {
4306        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
4307      } else {
4308        console.error('requestSource failed with error: ' + err);
4309      }
4310    })
4311    console.info('requestSource taskId: ' + taskId)
4312    photoAsset.cancelPhotoRequest(taskId);
4313  } catch (err) {
4314    console.error('cancelPhotoRequestDemo failed with error: ' + err)
4315  }
4316}
4317```
4318
4319### getAnalysisData<sup>11+</sup>
4320
4321getAnalysisData(analysisType: AnalysisType): Promise\<string>
4322
4323Obtains analysis data.
4324
4325**System API**: This is a system API.
4326
4327**Required permissions**: ohos.permission.READ\_IMAGEVIDEO
4328
4329**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4330
4331**Parameters**
4332
4333| Name         | Type          | Mandatory| Description          |
4334| :----------- | :----------- | :- | :----------- |
4335| analysisType | [AnalysisType](#analysistype11) | Yes | Smart analysis type.|
4336
4337**Error codes**
4338
4339For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4340
4341| ID   | Error Message                             |
4342| :------- | :-------------------------------- |
4343| 201      | Permission denied.                |
4344| 202      | Called by non-system application. |
4345| 401      | if parameter is invalid.          |
4346| 14000011 | System inner fail.                |
4347
4348**Example**
4349
4350```ts
4351import dataSharePredicates from '@ohos.data.dataSharePredicates';
4352
4353async function example() {
4354  try {
4355    console.info('getAnalysisDataDemo')
4356    let fetchOptions: photoAccessHelper.FetchOptions = {
4357      fetchColumns: [],
4358      predicates: new dataSharePredicates.DataSharePredicates()
4359    }
4360    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> =
4361      await phAccessHelper.getAssets(fetchOptions);
4362    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4363    if (photoAsset != undefined) {
4364      let analysisData: string = await photoAsset.getAnalysisData(
4365        photoAccessHelper.AnalysisType.ANALYSIS_OCR);
4366      console.info('get ocr result: ' + JSON.stringify(analysisData));
4367    }
4368    fetchResult.close();
4369  } catch (err) {
4370    console.error('getAnalysisDataDemofailed with error: ' + err)
4371  }
4372}
4373```
4374
4375## PhotoViewPicker
4376
4377Provides APIs for the user to select images and videos. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
4378
4379**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4380
4381**Example**
4382
4383```ts
4384let photoPicker = new photoAccessHelper.PhotoViewPicker();
4385```
4386
4387### select
4388
4389select(option?: PhotoSelectOptions) : Promise&lt;PhotoSelectResult&gt;
4390
4391Starts a **photoPicker** page for the user to select one or more images or videos. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
4392
4393> **NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
4394
4395**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4396
4397**Parameters**
4398
4399| Name | Type   | Mandatory| Description                      |
4400| ------- | ------- | ---- | -------------------------- |
4401| option | [PhotoSelectOptions](#photoselectoptions) | No  | Options for selecting files. If this parameter is not specified, images and videos are selected by default. A maximum of 50 files can be selected.|
4402
4403**Return value**
4404
4405| Type                           | Description   |
4406| ----------------------------- | :---- |
4407| Promise&lt;[PhotoSelectResult](#photoselectresult)&gt; | Promise return information about the images or videos selected.|
4408
4409**Error codes**
4410
4411For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4412
4413| ID| Error Message|
4414| -------- | ---------------------------------------- |
4415| 401      |  if parameter is invalid.         |
4416| 13900042      | Unknown error.         |
4417
4418**Example**
4419
4420```ts
4421import { BusinessError } from '@ohos.base';
4422async function example01() {
4423  try {
4424    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
4425    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
4426    PhotoSelectOptions.maxSelectNumber = 5;
4427    let photoPicker = new photoAccessHelper.PhotoViewPicker();
4428    photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
4429      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
4430    }).catch((err: BusinessError) => {
4431      console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
4432    });
4433  } catch (error) {
4434    let err: BusinessError = error as BusinessError;
4435    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
4436  }
4437}
4438```
4439
4440### select
4441
4442select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
4443
4444Starts a **photoPicker** page for the user to select one or more images or videos. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
4445
4446> **NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
4447
4448**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4449
4450**Parameters**
4451
4452| Name | Type   | Mandatory| Description                      |
4453| ------- | ------- | ---- | -------------------------- |
4454| option | [PhotoSelectOptions](#photoselectoptions) | Yes  | Options for selecting images or videos.|
4455| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback invoked to return information about the images or videos selected.|
4456
4457**Error codes**
4458
4459For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4460
4461| ID| Error Message|
4462| -------- | ---------------------------------------- |
4463| 401      |  if parameter is invalid.         |
4464| 13900042      | Unknown error.         |
4465
4466**Example**
4467
4468```ts
4469import { BusinessError } from '@ohos.base';
4470async function example02() {
4471  try {
4472    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
4473    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
4474    PhotoSelectOptions.maxSelectNumber = 5;
4475    let photoPicker = new photoAccessHelper.PhotoViewPicker();
4476    photoPicker.select(PhotoSelectOptions, (err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
4477      if (err) {
4478        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
4479        return;
4480      }
4481      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
4482    });
4483  } catch (error) {
4484    let err: BusinessError = error as BusinessError;
4485    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
4486  }
4487}
4488```
4489
4490### select
4491
4492select(callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
4493
4494Starts a **photoPicker** page for the user to select one or more images or videos. This API uses an asynchronous callback to return the result.
4495
4496> **NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
4497
4498**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4499
4500**Parameters**
4501
4502| Name | Type   | Mandatory| Description                      |
4503| ------- | ------- | ---- | -------------------------- |
4504| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback invoked to return information about the images or videos selected.|
4505
4506**Error codes**
4507
4508For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4509
4510| ID| Error Message|
4511| -------- | ---------------------------------------- |
4512| 401      |  if parameter is invalid.         |
4513| 13900042      | Unknown error.         |
4514
4515**Example**
4516
4517```ts
4518import { BusinessError } from '@ohos.base';
4519async function example03() {
4520  try {
4521    let photoPicker = new photoAccessHelper.PhotoViewPicker();
4522    photoPicker.select((err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
4523      if (err) {
4524        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
4525        return;
4526      }
4527      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
4528    });
4529  } catch (error) {
4530    let err: BusinessError = error as BusinessError;
4531    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
4532  }
4533}
4534```
4535
4536## FetchResult
4537
4538Provides APIs to manage the file retrieval result.
4539
4540### getCount
4541
4542getCount(): number
4543
4544Obtains the total number of files in the result set.
4545
4546**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4547
4548**Return value**
4549
4550| Type    | Description      |
4551| ------ | -------- |
4552| number | Returns the total number of files obtained.|
4553
4554**Error codes**
4555
4556For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4557
4558| ID| Error Message|
4559| -------- | ---------------------------------------- |
4560| 401       |  if parameter is invalid.         |
4561| 13900020     | Invalid argument.         |
4562| 14000011       | System inner fail.         |
4563
4564**Example**
4565
4566```ts
4567import dataSharePredicates from '@ohos.data.dataSharePredicates';
4568
4569async function example() {
4570  console.info('getCountDemo');
4571  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4572  let fetchOption: photoAccessHelper.FetchOptions = {
4573    fetchColumns: [],
4574    predicates: predicates
4575  };
4576  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4577  let fetchCount = fetchResult.getCount();
4578  console.info('fetchCount = ', fetchCount);
4579}
4580```
4581
4582### isAfterLast
4583
4584isAfterLast(): boolean
4585
4586Checks whether the cursor is in the last row of the result set.
4587
4588**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4589
4590**Return value**
4591
4592| Type     | Description                                |
4593| ------- | ---------------------------------- |
4594| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.|
4595
4596**Error codes**
4597
4598For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4599
4600| ID| Error Message|
4601| -------- | ---------------------------------------- |
4602| 401       |  if parameter is invalid.         |
4603| 13900020     | Invalid argument.         |
4604| 14000011       | System inner fail.         |
4605
4606**Example**
4607
4608```ts
4609import dataSharePredicates from '@ohos.data.dataSharePredicates';
4610
4611async function example() {
4612  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4613  let fetchOption: photoAccessHelper.FetchOptions = {
4614    fetchColumns: [],
4615    predicates: predicates
4616  };
4617  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4618  let fetchCount = fetchResult.getCount();
4619  console.info('count:' + fetchCount);
4620  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
4621  if (fetchResult.isAfterLast()) {
4622    console.info('photoAsset isAfterLast displayName = ', photoAsset.displayName);
4623  } else {
4624    console.info('photoAsset not isAfterLast.');
4625  }
4626}
4627```
4628
4629### close
4630
4631close(): void
4632
4633Closes this **FetchFileResult** instance to invalidate it. After this instance is closed, the APIs in this instance cannot be invoked.
4634
4635**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4636
4637**Error codes**
4638
4639For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4640
4641| ID| Error Message|
4642| -------- | ---------------------------------------- |
4643| 401       |  if parameter is invalid.         |
4644| 13900020     | Invalid argument.         |
4645| 14000011       | System inner fail.         |
4646
4647**Example**
4648
4649```ts
4650import dataSharePredicates from '@ohos.data.dataSharePredicates';
4651
4652async function example() {
4653  console.info('fetchResultCloseDemo');
4654  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4655  let fetchOption: photoAccessHelper.FetchOptions = {
4656    fetchColumns: [],
4657    predicates: predicates
4658  };
4659  try {
4660    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4661    fetchResult.close();
4662    console.info('close succeed.');
4663  } catch (err) {
4664    console.error('close fail. message = ' + err);
4665  }
4666}
4667```
4668
4669### getFirstObject
4670
4671getFirstObject(callback: AsyncCallback&lt;T&gt;): void
4672
4673Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result.
4674
4675**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4676
4677**Parameters**
4678
4679| Name  | Type                                         | Mandatory| Description                                       |
4680| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
4681| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the first file asset obtained.|
4682
4683**Error codes**
4684
4685For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4686
4687| ID| Error Message|
4688| -------- | ---------------------------------------- |
4689| 401       |  if parameter is invalid.         |
4690| 13900020     | Invalid argument.         |
4691| 14000011       | System inner fail.         |
4692
4693**Example**
4694
4695```ts
4696import dataSharePredicates from '@ohos.data.dataSharePredicates';
4697
4698async function example() {
4699  console.info('getFirstObjectDemo');
4700  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4701  let fetchOption: photoAccessHelper.FetchOptions = {
4702    fetchColumns: [],
4703    predicates: predicates
4704  };
4705  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4706  fetchResult.getFirstObject((err, photoAsset) => {
4707    if (photoAsset !== undefined) {
4708      console.info('photoAsset displayName: ', photoAsset.displayName);
4709    } else {
4710      console.error('photoAsset failed with err:' + err);
4711    }
4712  });
4713}
4714```
4715
4716### getFirstObject
4717
4718getFirstObject(): Promise&lt;T&gt;
4719
4720Obtains the first file asset in the result set. This API uses a promise to return the result.
4721
4722**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4723
4724**Return value**
4725
4726| Type                                   | Description                      |
4727| --------------------------------------- | -------------------------- |
4728| Promise&lt;T&gt; | Promise used to return the first object in the result set.|
4729
4730**Error codes**
4731
4732For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4733
4734| ID| Error Message|
4735| -------- | ---------------------------------------- |
4736| 401       |  if parameter is invalid.         |
4737| 13900020     | Invalid argument.         |
4738| 14000011       | System inner fail.         |
4739
4740**Example**
4741
4742```ts
4743import dataSharePredicates from '@ohos.data.dataSharePredicates';
4744
4745async function example() {
4746  console.info('getFirstObjectDemo');
4747  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4748  let fetchOption: photoAccessHelper.FetchOptions = {
4749    fetchColumns: [],
4750    predicates: predicates
4751  };
4752  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4753  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4754  console.info('photoAsset displayName: ', photoAsset.displayName);
4755}
4756```
4757
4758### getNextObject
4759
4760getNextObject(callback: AsyncCallback&lt;T&gt;): void
4761
4762Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
4763Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
4764
4765**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4766
4767**Parameters**
4768
4769| Name   | Type                                         | Mandatory| Description                                     |
4770| --------- | --------------------------------------------- | ---- | ----------------------------------------- |
4771| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the next file asset.|
4772
4773**Error codes**
4774
4775For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4776
4777| ID| Error Message|
4778| -------- | ---------------------------------------- |
4779| 401       |  if parameter is invalid.         |
4780| 13900020     | Invalid argument.         |
4781| 14000011       | System inner fail.         |
4782
4783**Example**
4784
4785```ts
4786import dataSharePredicates from '@ohos.data.dataSharePredicates';
4787
4788async function example() {
4789  console.info('getNextObjectDemo');
4790  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4791  let fetchOption: photoAccessHelper.FetchOptions = {
4792    fetchColumns: [],
4793    predicates: predicates
4794  };
4795  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4796  await fetchResult.getFirstObject();
4797  if (!fetchResult.isAfterLast()) {
4798    fetchResult.getNextObject((err, photoAsset) => {
4799      if (photoAsset !== undefined) {
4800        console.info('photoAsset displayName: ', photoAsset.displayName);
4801      } else {
4802        console.error('photoAsset failed with err: ' + err);
4803      }
4804    });
4805  }
4806}
4807```
4808
4809### getNextObject
4810
4811getNextObject(): Promise&lt;T&gt;
4812
4813Obtains the next file asset in the result set. This API uses a promise to return the result.
4814Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
4815
4816**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4817
4818**Return value**
4819
4820| Type                                   | Description             |
4821| --------------------------------------- | ----------------- |
4822| Promise&lt;T&gt; | Promise used to return the next object in the result set.|
4823
4824**Error codes**
4825
4826For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4827
4828| ID| Error Message|
4829| -------- | ---------------------------------------- |
4830| 401       |  if parameter is invalid.         |
4831| 13900020     | Invalid argument.         |
4832| 14000011       | System inner fail.         |
4833
4834**Example**
4835
4836```ts
4837import dataSharePredicates from '@ohos.data.dataSharePredicates';
4838
4839async function example() {
4840  console.info('getNextObjectDemo');
4841  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4842  let fetchOption: photoAccessHelper.FetchOptions = {
4843    fetchColumns: [],
4844    predicates: predicates
4845  };
4846  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4847  await fetchResult.getFirstObject();
4848  if (!fetchResult.isAfterLast()) {
4849    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getNextObject();
4850    console.info('photoAsset displayName: ', photoAsset.displayName);
4851  }
4852}
4853```
4854
4855### getLastObject
4856
4857getLastObject(callback: AsyncCallback&lt;T&gt;): void
4858
4859Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result.
4860
4861**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4862
4863**Parameters**
4864
4865| Name  | Type                                         | Mandatory| Description                       |
4866| -------- | --------------------------------------------- | ---- | --------------------------- |
4867| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the last file asset obtained.|
4868
4869**Error codes**
4870
4871For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4872
4873| ID| Error Message|
4874| -------- | ---------------------------------------- |
4875| 401       |  if parameter is invalid.         |
4876| 13900020     | Invalid argument.         |
4877| 14000011       | System inner fail.         |
4878
4879**Example**
4880
4881```ts
4882import dataSharePredicates from '@ohos.data.dataSharePredicates';
4883
4884async function example() {
4885  console.info('getLastObjectDemo');
4886  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4887  let fetchOption: photoAccessHelper.FetchOptions = {
4888    fetchColumns: [],
4889    predicates: predicates
4890  };
4891  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4892  fetchResult.getLastObject((err, photoAsset) => {
4893    if (photoAsset !== undefined) {
4894      console.info('photoAsset displayName: ', photoAsset.displayName);
4895    } else {
4896      console.error('photoAsset failed with err: ' + err);
4897    }
4898  });
4899}
4900```
4901
4902### getLastObject
4903
4904getLastObject(): Promise&lt;T&gt;
4905
4906Obtains the last file asset in the result set. This API uses a promise to return the result.
4907
4908**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4909
4910**Return value**
4911
4912| Type                                   | Description             |
4913| --------------------------------------- | ----------------- |
4914| Promise&lt;T&gt; | Promise used to return the last object in the result set.|
4915
4916**Error codes**
4917
4918For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4919
4920| ID| Error Message|
4921| -------- | ---------------------------------------- |
4922| 401       |  if parameter is invalid.         |
4923| 13900020     | Invalid argument.         |
4924| 14000011       | System inner fail.         |
4925
4926**Example**
4927
4928```ts
4929import dataSharePredicates from '@ohos.data.dataSharePredicates';
4930
4931async function example() {
4932  console.info('getLastObjectDemo');
4933  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4934  let fetchOption: photoAccessHelper.FetchOptions = {
4935    fetchColumns: [],
4936    predicates: predicates
4937  };
4938  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4939  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
4940  console.info('photoAsset displayName: ', photoAsset.displayName);
4941}
4942```
4943
4944### getObjectByPosition
4945
4946getObjectByPosition(index: number, callback: AsyncCallback&lt;T&gt;): void
4947
4948Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result.
4949
4950**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4951
4952**Parameters**
4953
4954| Name      | Type                                      | Mandatory  | Description                |
4955| -------- | ---------------------------------------- | ---- | ------------------ |
4956| index    | number                                   | Yes   | Index of the file asset to obtain. The value starts from **0**.    |
4957| callback | AsyncCallback&lt;T&gt; | Yes   | Callback invoked to return the file asset obtained.|
4958
4959**Error codes**
4960
4961For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4962
4963| ID| Error Message|
4964| -------- | ---------------------------------------- |
4965| 401       |  if parameter is invalid.         |
4966| 13900020     | Invalid argument.         |
4967| 14000011       | System inner fail.         |
4968
4969**Example**
4970
4971```ts
4972import dataSharePredicates from '@ohos.data.dataSharePredicates';
4973
4974async function example() {
4975  console.info('getObjectByPositionDemo');
4976  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4977  let fetchOption: photoAccessHelper.FetchOptions = {
4978    fetchColumns: [],
4979    predicates: predicates
4980  };
4981  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4982  fetchResult.getObjectByPosition(0, (err, photoAsset) => {
4983    if (photoAsset !== undefined) {
4984      console.info('photoAsset displayName: ', photoAsset.displayName);
4985    } else {
4986      console.error('photoAsset failed with err: ' + err);
4987    }
4988  });
4989}
4990```
4991
4992### getObjectByPosition
4993
4994getObjectByPosition(index: number): Promise&lt;T&gt;
4995
4996Obtains a file asset with the specified index in the result set. This API uses a promise to return the result.
4997
4998**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4999
5000**Parameters**
5001
5002| Name   | Type    | Mandatory  | Description            |
5003| ----- | ------ | ---- | -------------- |
5004| index | number | Yes   | Index of the file asset to obtain. The value starts from **0**.|
5005
5006**Return value**
5007
5008| Type                                   | Description             |
5009| --------------------------------------- | ----------------- |
5010| Promise&lt;T&gt; | Promise used to return the file asset obtained.|
5011
5012**Error codes**
5013
5014For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5015
5016| ID| Error Message|
5017| -------- | ---------------------------------------- |
5018| 401       |  if parameter is invalid.         |
5019| 13900020     | Invalid argument.         |
5020| 14000011       | System inner fail.         |
5021
5022**Example**
5023
5024```ts
5025import dataSharePredicates from '@ohos.data.dataSharePredicates';
5026
5027async function example() {
5028  console.info('getObjectByPositionDemo');
5029  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5030  let fetchOption: photoAccessHelper.FetchOptions = {
5031    fetchColumns: [],
5032    predicates: predicates
5033  };
5034  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5035  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getObjectByPosition(0);
5036  console.info('photoAsset displayName: ', photoAsset.displayName);
5037}
5038```
5039
5040### getAllObjects
5041
5042getAllObjects(callback: AsyncCallback&lt;Array&lt;T&gt;&gt;): void
5043
5044Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result.
5045
5046**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5047
5048**Parameters**
5049
5050| Name  | Type                                         | Mandatory| Description                                       |
5051| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
5052| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | Yes  | Callback invoked to return an array of all file assets in the result set.|
5053
5054**Error codes**
5055
5056For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5057
5058| ID| Error Message|
5059| -------- | ---------------------------------------- |
5060| 401       |  if parameter is invalid.         |
5061| 13900020     | Invalid argument.         |
5062| 14000011       | System inner fail.         |
5063
5064**Example**
5065
5066```ts
5067import dataSharePredicates from '@ohos.data.dataSharePredicates';
5068
5069async function example() {
5070  console.info('getAllObjectDemo');
5071  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5072  let fetchOption: photoAccessHelper.FetchOptions = {
5073    fetchColumns: [],
5074    predicates: predicates
5075  };
5076  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5077  fetchResult.getAllObjects((err, photoAssetList) => {
5078    if (photoAssetList !== undefined) {
5079      console.info('photoAssetList length: ', photoAssetList.length);
5080    } else {
5081      console.error('photoAssetList failed with err:' + err);
5082    }
5083  });
5084}
5085```
5086
5087### getAllObjects
5088
5089getAllObjects(): Promise&lt;Array&lt;T&gt;&gt;
5090
5091Obtains all the file assets in the result set. This API uses a promise to return the result.
5092
5093**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5094
5095**Return value**
5096
5097| Type                                   | Description                      |
5098| --------------------------------------- | -------------------------- |
5099| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return an array of all file assets in the result set.|
5100
5101**Error codes**
5102
5103For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5104
5105| ID| Error Message|
5106| -------- | ---------------------------------------- |
5107| 401       |  if parameter is invalid.         |
5108| 13900020     | Invalid argument.         |
5109| 14000011       | System inner fail.         |
5110
5111**Example**
5112
5113```ts
5114import dataSharePredicates from '@ohos.data.dataSharePredicates';
5115
5116async function example() {
5117  console.info('getAllObjectDemo');
5118  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5119  let fetchOption: photoAccessHelper.FetchOptions = {
5120    fetchColumns: [],
5121    predicates: predicates
5122  };
5123  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5124  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
5125  console.info('photoAssetList length: ', photoAssetList.length);
5126}
5127```
5128
5129## Album
5130
5131Provides APIs to manage albums.
5132
5133### Attributes
5134
5135**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5136
5137| Name          | Type   | Readable  | Writable | Description  |
5138| ------------ | ------ | ---- | ---- | ------- |
5139| albumType | [AlbumType]( #albumtype) | Yes   | No   | Type of the album.   |
5140| albumSubtype | [AlbumSubtype]( #albumsubtype) | Yes   | No  | Subtype of the album.   |
5141| albumName | string | Yes   | Yes for a user album; no for a system album.  | Name of the album.   |
5142| albumUri | string | Yes   | No   | URI of the album.  |
5143| count | number | Yes   | No   |  Number of files in the album.|
5144| coverUri | string | Yes   | No   | URI of the cover file of the album.|
5145| imageCount<sup>11+</sup> | number | Yes  | No  | Number of images in the album.|
5146| videoCount<sup>11+</sup> | number | Yes  | No  | Number of videos in the album.|
5147
5148### getAssets
5149
5150getAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;PhotoAsset&gt;&gt;): void
5151
5152Obtains image and video assets. This API uses an asynchronous callback to return the result.
5153
5154**Required permissions**: ohos.permission.READ_IMAGEVIDEO
5155
5156**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5157
5158**Parameters**
5159
5160| Name  | Type                     | Mandatory| Description      |
5161| -------- | ------------------------- | ---- | ---------- |
5162| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the assets.|
5163| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Yes  | Callback invoked to return the image and video assets obtained.|
5164
5165**Error codes**
5166
5167For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5168
5169| ID| Error Message|
5170| -------- | ---------------------------------------- |
5171| 401       |  if parameter is invalid.         |
5172| 13900012     | Permission denied.         |
5173| 13900020     | Invalid argument.         |
5174| 14000011       | System inner fail.         |
5175
5176**Example**
5177
5178```ts
5179import dataSharePredicates from '@ohos.data.dataSharePredicates';
5180
5181async function example() {
5182  console.info('albumGetAssetsDemoCallback');
5183  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5184  let albumFetchOptions: photoAccessHelper.FetchOptions = {
5185    fetchColumns: [],
5186    predicates: predicates
5187  };
5188  let fetchOption: photoAccessHelper.FetchOptions = {
5189    fetchColumns: [],
5190    predicates: predicates
5191  };
5192  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
5193  let album: photoAccessHelper.Album = await albumList.getFirstObject();
5194  album.getAssets(fetchOption, (err, albumFetchResult) => {
5195    if (albumFetchResult !== undefined) {
5196      console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
5197    } else {
5198      console.error('album getAssets failed with error: ' + err);
5199    }
5200  });
5201}
5202```
5203
5204### getAssets
5205
5206getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
5207
5208Obtains image and video assets. This API uses a promise to return the result.
5209
5210**Required permissions**: ohos.permission.READ_IMAGEVIDEO
5211
5212**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5213
5214**Parameters**
5215
5216| Name  | Type                     | Mandatory| Description      |
5217| -------- | ------------------------- | ---- | ---------- |
5218| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the album files.|
5219
5220**Return value**
5221
5222| Type                                   | Description             |
5223| --------------------------------------- | ----------------- |
5224| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the image and video assets obtained.|
5225
5226**Error codes**
5227
5228For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5229
5230| ID| Error Message|
5231| -------- | ---------------------------------------- |
5232| 401       |  if parameter is invalid.         |
5233| 13900012     | Permission denied.         |
5234| 13900020     | Invalid argument.         |
5235| 14000011       | System inner fail.         |
5236
5237**Example**
5238
5239```ts
5240import dataSharePredicates from '@ohos.data.dataSharePredicates';
5241import { BusinessError } from '@ohos.base';
5242
5243async function example() {
5244  console.info('albumGetAssetsDemoPromise');
5245  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5246  let albumFetchOptions: photoAccessHelper.FetchOptions = {
5247    fetchColumns: [],
5248    predicates: predicates
5249  };
5250  let fetchOption: photoAccessHelper.FetchOptions = {
5251    fetchColumns: [],
5252    predicates: predicates
5253  };
5254  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
5255  let album: photoAccessHelper.Album = await albumList.getFirstObject();
5256  album.getAssets(fetchOption).then((albumFetchResult) => {
5257    console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
5258  }).catch((err: BusinessError) => {
5259    console.error('album getAssets failed with error: ' + err);
5260  });
5261}
5262```
5263
5264### commitModify
5265
5266commitModify(callback: AsyncCallback&lt;void&gt;): void
5267
5268Commits the modification on the album attributes to the database. This API uses an asynchronous callback to return the result.
5269
5270**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5271
5272**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5273
5274**Parameters**
5275
5276| Name  | Type                     | Mandatory| Description      |
5277| -------- | ------------------------- | ---- | ---------- |
5278| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5279
5280**Error codes**
5281
5282For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5283
5284| ID| Error Message|
5285| -------- | ---------------------------------------- |
5286| 401       |  if parameter is invalid.         |
5287| 13900012     | Permission denied.         |
5288| 13900020     | Invalid argument.         |
5289| 14000011       | System inner fail.         |
5290
5291**Example**
5292
5293```ts
5294import dataSharePredicates from '@ohos.data.dataSharePredicates';
5295
5296async function example() {
5297  console.info('albumCommitModifyDemo');
5298  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5299  let albumFetchOptions: photoAccessHelper.FetchOptions = {
5300    fetchColumns: [],
5301    predicates: predicates
5302  };
5303  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
5304  let album: photoAccessHelper.Album = await albumList.getFirstObject();
5305  album.albumName = 'hello';
5306  album.commitModify((err) => {
5307    if (err !== undefined) {
5308      console.error('commitModify failed with error: ' + err);
5309    } else {
5310      console.info('commitModify successfully');
5311    }
5312  });
5313}
5314```
5315
5316### commitModify
5317
5318commitModify(): Promise&lt;void&gt;
5319
5320Commits the modification on the album attributes to the database. This API uses a promise to return the result.
5321
5322**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5323
5324**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5325
5326**Return value**
5327
5328| Type                 | Description          |
5329| ------------------- | ------------ |
5330| Promise&lt;void&gt; | Promise that returns no value.|
5331
5332**Error codes**
5333
5334For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5335
5336| ID| Error Message|
5337| -------- | ---------------------------------------- |
5338| 401       |  if parameter is invalid.         |
5339| 13900012     | Permission denied.         |
5340| 13900020     | Invalid argument.         |
5341| 14000011       | System inner fail.         |
5342
5343**Example**
5344
5345```ts
5346import dataSharePredicates from '@ohos.data.dataSharePredicates';
5347import { BusinessError } from '@ohos.base';
5348
5349async function example() {
5350  console.info('albumCommitModifyDemo');
5351  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5352  let albumFetchOptions: photoAccessHelper.FetchOptions = {
5353    fetchColumns: [],
5354    predicates: predicates
5355  };
5356  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
5357  let album: photoAccessHelper.Album = await albumList.getFirstObject();
5358  album.albumName = 'hello';
5359  album.commitModify().then(() => {
5360    console.info('commitModify successfully');
5361  }).catch((err: BusinessError) => {
5362    console.error('commitModify failed with error: ' + err);
5363  });
5364}
5365```
5366
5367### addAssets<sup>(deprecated)</sup>
5368
5369addAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
5370
5371Adds image and video assets to an album. Before the operation, ensure that the image and video assets to add and the album exist. This API uses an asynchronous callback to return the result.
5372
5373> **NOTE**
5374>
5375> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
5376
5377**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5378
5379**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5380
5381**Parameters**
5382
5383| Name  | Type                     | Mandatory| Description      |
5384| -------- | ------------------------- | ---- | ---------- |
5385| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
5386| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5387
5388**Error codes**
5389
5390For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5391
5392| ID| Error Message|
5393| -------- | ---------------------------------------- |
5394| 401       |  if parameter is invalid.         |
5395| 13900012     | Permission denied.         |
5396| 13900020     | Invalid argument.         |
5397| 14000011       | System inner fail.         |
5398
5399**Example**
5400
5401```ts
5402import dataSharePredicates from '@ohos.data.dataSharePredicates';
5403
5404async function example() {
5405  try {
5406    console.info('addAssetsDemoCallback');
5407    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5408    let fetchOption: photoAccessHelper.FetchOptions = {
5409      fetchColumns: [],
5410      predicates: predicates
5411    };
5412    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5413    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5414    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5415    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5416    album.addAssets([asset], (err) => {
5417      if (err === undefined) {
5418        console.info('album addAssets successfully');
5419      } else {
5420        console.error('album addAssets failed with error: ' + err);
5421      }
5422    });
5423  } catch (err) {
5424    console.error('addAssetsDemoCallback failed with error: ' + err);
5425  }
5426}
5427```
5428
5429### addAssets<sup>(deprecated)</sup>
5430
5431addAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
5432
5433Adds image and video assets to an album. Before the operation, ensure that the image and video assets to add and the album exist. This API uses a promise to return the result.
5434
5435> **NOTE**
5436>
5437> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
5438
5439**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5440
5441**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5442
5443**Parameters**
5444
5445| Name  | Type                     | Mandatory| Description      |
5446| -------- | ------------------------- | ---- | ---------- |
5447| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
5448
5449**Return value**
5450
5451| Type                                   | Description             |
5452| --------------------------------------- | ----------------- |
5453|Promise&lt;void&gt; | Promise that returns no value.|
5454
5455**Error codes**
5456
5457For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5458
5459| ID| Error Message|
5460| -------- | ---------------------------------------- |
5461| 401       |  if parameter is invalid.         |
5462| 13900012     | Permission denied.         |
5463| 13900020     | Invalid argument.         |
5464| 14000011       | System inner fail.         |
5465
5466**Example**
5467
5468```ts
5469import dataSharePredicates from '@ohos.data.dataSharePredicates';
5470import { BusinessError } from '@ohos.base';
5471
5472async function example() {
5473  try {
5474    console.info('addAssetsDemoPromise');
5475    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5476    let fetchOption: photoAccessHelper.FetchOptions = {
5477      fetchColumns: [],
5478      predicates: predicates
5479    };
5480    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5481    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5482    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5483    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5484    album.addAssets([asset]).then(() => {
5485      console.info('album addAssets successfully');
5486    }).catch((err: BusinessError) => {
5487      console.error('album addAssets failed with error: ' + err);
5488    });
5489  } catch (err) {
5490    console.error('addAssetsDemoPromise failed with error: ' + err);
5491  }
5492}
5493```
5494
5495### removeAssets<sup>(deprecated)</sup>
5496
5497removeAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
5498
5499Removes image and video assets from an album. The album and file resources must exist. This API uses an asynchronous callback to return the result.
5500
5501> **NOTE**
5502>
5503> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
5504
5505**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5506
5507**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5508
5509**Parameters**
5510
5511| Name  | Type                     | Mandatory| Description      |
5512| -------- | ------------------------- | ---- | ---------- |
5513| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
5514| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5515
5516**Error codes**
5517
5518For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5519
5520| ID| Error Message|
5521| -------- | ---------------------------------------- |
5522| 401       |  if parameter is invalid.         |
5523| 13900012     | Permission denied.         |
5524| 13900020     | Invalid argument.         |
5525| 14000011       | System inner fail.         |
5526
5527**Example**
5528
5529```ts
5530import dataSharePredicates from '@ohos.data.dataSharePredicates';
5531
5532async function example() {
5533  try {
5534    console.info('removeAssetsDemoCallback');
5535    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5536    let fetchOption: photoAccessHelper.FetchOptions = {
5537      fetchColumns: [],
5538      predicates: predicates
5539    };
5540    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5541    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5542    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5543    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5544    album.removeAssets([asset], (err) => {
5545      if (err === undefined) {
5546        console.info('album removeAssets successfully');
5547      } else {
5548        console.error('album removeAssets failed with error: ' + err);
5549      }
5550    });
5551  } catch (err) {
5552    console.error('removeAssetsDemoCallback failed with error: ' + err);
5553  }
5554}
5555```
5556
5557### removeAssets<sup>(deprecated)</sup>
5558
5559removeAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
5560
5561Removes image and video assets from an album. The album and file resources must exist. This API uses a promise to return the result.
5562
5563> **NOTE**
5564>
5565> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
5566
5567**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5568
5569**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5570
5571**Parameters**
5572
5573| Name  | Type                     | Mandatory| Description      |
5574| -------- | ------------------------- | ---- | ---------- |
5575| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
5576
5577**Return value**
5578
5579| Type                                   | Description             |
5580| --------------------------------------- | ----------------- |
5581|Promise&lt;void&gt; | Promise that returns no value.|
5582
5583**Error codes**
5584
5585For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5586
5587| ID| Error Message|
5588| -------- | ---------------------------------------- |
5589| 401       |  if parameter is invalid.         |
5590| 13900012     | Permission denied.         |
5591| 13900020     | Invalid argument.         |
5592| 14000011       | System inner fail.         |
5593
5594**Example**
5595
5596```ts
5597import dataSharePredicates from '@ohos.data.dataSharePredicates';
5598import { BusinessError } from '@ohos.base';
5599
5600async function example() {
5601  try {
5602    console.info('removeAssetsDemoPromise');
5603    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5604    let fetchOption: photoAccessHelper.FetchOptions = {
5605      fetchColumns: [],
5606      predicates: predicates
5607    };
5608    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5609    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5610    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5611    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5612    album.removeAssets([asset]).then(() => {
5613      console.info('album removeAssets successfully');
5614    }).catch((err: BusinessError) => {
5615      console.error('album removeAssets failed with error: ' + err);
5616    });
5617  } catch (err) {
5618    console.error('removeAssetsDemoPromise failed with error: ' + err);
5619  }
5620}
5621```
5622
5623### recoverAssets<sup>(deprecated)</sup>
5624
5625recoverAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
5626
5627Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
5628
5629> **NOTE**
5630>
5631> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.recoverAssets](#recoverassets11) instead.
5632
5633**System API**: This is a system API.
5634
5635**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5636
5637**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5638
5639**Parameters**
5640
5641| Name  | Type                     | Mandatory| Description      |
5642| -------- | ------------------------- | ---- | ---------- |
5643| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image or video assets to recover.|
5644| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5645
5646**Error codes**
5647
5648For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5649
5650| ID| Error Message|
5651| -------- | ---------------------------------------- |
5652| 202      |  Called by non-system application.         |
5653| 401      |  if parameter is invalid.         |
5654| 13900012     | Permission denied.         |
5655| 13900020     | Invalid argument.         |
5656| 14000011       | System inner fail.         |
5657
5658**Example**
5659
5660```ts
5661import dataSharePredicates from '@ohos.data.dataSharePredicates';
5662
5663async function example() {
5664  try {
5665    console.info('recoverAssetsDemoCallback');
5666    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5667    let fetchOption: photoAccessHelper.FetchOptions = {
5668      fetchColumns: [],
5669      predicates: predicates
5670    };
5671    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5672    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5673    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5674    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5675    album.recoverAssets([asset], (err) => {
5676      if (err === undefined) {
5677        console.info('album recoverAssets successfully');
5678      } else {
5679        console.error('album recoverAssets failed with error: ' + err);
5680      }
5681    });
5682  } catch (err) {
5683    console.error('recoverAssetsDemoCallback failed with error: ' + err);
5684  }
5685}
5686```
5687
5688### recoverAssets<sup>(deprecated)</sup>
5689
5690recoverAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
5691
5692Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
5693
5694> **NOTE**
5695>
5696> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.recoverAssets](#recoverassets11) instead.
5697
5698**System API**: This is a system API.
5699
5700**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5701
5702**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5703
5704**Parameters**
5705
5706| Name  | Type                     | Mandatory| Description      |
5707| -------- | ------------------------- | ---- | ---------- |
5708| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image or video assets to recover.|
5709
5710**Return value**
5711
5712| Type                                   | Description             |
5713| --------------------------------------- | ----------------- |
5714|Promise&lt;void&gt; | Promise that returns no value.|
5715
5716**Error codes**
5717
5718For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5719
5720| ID| Error Message|
5721| -------- | ---------------------------------------- |
5722| 202      |  Called by non-system application.         |
5723| 401      |  if parameter is invalid.         |
5724| 13900012     | Permission denied.         |
5725| 13900020     | Invalid argument.         |
5726| 14000011       | System inner fail.         |
5727
5728**Example**
5729
5730```ts
5731import dataSharePredicates from '@ohos.data.dataSharePredicates';
5732import { BusinessError } from '@ohos.base';
5733
5734async function example() {
5735  try {
5736    console.info('recoverAssetsDemoPromise');
5737    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5738    let fetchOption: photoAccessHelper.FetchOptions = {
5739      fetchColumns: [],
5740      predicates: predicates
5741    };
5742    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5743    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5744    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5745    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5746    album.recoverAssets([asset]).then(() => {
5747      console.info('album recoverAssets successfully');
5748    }).catch((err: BusinessError) => {
5749      console.error('album recoverAssets failed with error: ' + err);
5750    });
5751  } catch (err) {
5752    console.error('recoverAssetsDemoPromise failed with error: ' + err);
5753  }
5754}
5755```
5756
5757### deleteAssets<sup>(deprecated)</sup>
5758
5759deleteAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
5760
5761Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
5762
5763> **NOTE**
5764>
5765> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAssets](#deleteassets11-2) instead.
5766
5767**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
5768
5769**System API**: This is a system API.
5770
5771**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5772
5773**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5774
5775**Parameters**
5776
5777| Name  | Type                     | Mandatory| Description      |
5778| -------- | ------------------------- | ---- | ---------- |
5779| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image or video assets to delete.|
5780| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5781
5782**Error codes**
5783
5784For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5785
5786| ID| Error Message|
5787| -------- | ---------------------------------------- |
5788| 202      |  Called by non-system application.         |
5789| 401      |  if parameter is invalid.         |
5790| 13900012     | Permission denied.         |
5791| 13900020     | Invalid argument.         |
5792| 14000011       | System inner fail.         |
5793
5794**Example**
5795
5796```ts
5797import dataSharePredicates from '@ohos.data.dataSharePredicates';
5798
5799async function example() {
5800  try {
5801    console.info('deleteAssetsDemoCallback');
5802    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5803    let fetchOption: photoAccessHelper.FetchOptions = {
5804      fetchColumns: [],
5805      predicates: predicates
5806    };
5807    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5808    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5809    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5810    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5811    album.deleteAssets([asset], (err) => {
5812      if (err === undefined) {
5813        console.info('album deleteAssets successfully');
5814      } else {
5815        console.error('album deleteAssets failed with error: ' + err);
5816      }
5817    });
5818  } catch (err) {
5819    console.error('deleteAssetsDemoCallback failed with error: ' + err);
5820  }
5821}
5822```
5823
5824### deleteAssets<sup>(deprecated)</sup>
5825
5826deleteAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
5827
5828Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
5829
5830> **NOTE**
5831>
5832> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAssets](#deleteassets11-2) instead.
5833
5834**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
5835
5836**System API**: This is a system API.
5837
5838**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5839
5840**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5841
5842**Parameters**
5843
5844| Name  | Type                     | Mandatory| Description      |
5845| -------- | ------------------------- | ---- | ---------- |
5846| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image or video assets to delete.|
5847
5848**Return value**
5849
5850| Type                                   | Description             |
5851| --------------------------------------- | ----------------- |
5852|Promise&lt;void&gt; | Promise that returns no value.|
5853
5854**Error codes**
5855
5856For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5857
5858| ID| Error Message|
5859| -------- | ---------------------------------------- |
5860| 202      |  Called by non-system application.         |
5861| 401      |  if parameter is invalid.         |
5862| 13900012     | Permission denied.         |
5863| 13900020     | Invalid argument.         |
5864| 14000011       | System inner fail.         |
5865
5866**Example**
5867
5868```ts
5869import dataSharePredicates from '@ohos.data.dataSharePredicates';
5870import { BusinessError } from '@ohos.base';
5871
5872async function example() {
5873  try {
5874    console.info('deleteAssetsDemoPromise');
5875    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5876    let fetchOption: photoAccessHelper.FetchOptions = {
5877      fetchColumns: [],
5878      predicates: predicates
5879    };
5880    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5881    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5882    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5883    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5884    album.deleteAssets([asset]).then(() => {
5885      console.info('album deleteAssets successfully');
5886    }).catch((err: BusinessError) => {
5887      console.error('album deleteAssets failed with error: ' + err);
5888    });
5889  } catch (err) {
5890    console.error('deleteAssetsDemoPromise failed with error: ' + err);
5891  }
5892}
5893```
5894
5895### setCoverUri<sup>(deprecated)</sup>
5896
5897setCoverUri(uri: string, callback: AsyncCallback&lt;void&gt;): void
5898
5899Sets the album cover. This API uses an asynchronous callback to return the result.
5900
5901> **NOTE**
5902>
5903> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.setCoverUri](#setcoveruri11) instead.
5904
5905> **NOTE**<br>This API can be used to set the user album cover, but not the system album cover.
5906
5907**System API**: This is a system API.
5908
5909**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5910
5911**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5912
5913**Parameters**
5914
5915| Name  | Type                     | Mandatory| Description      |
5916| -------- | ------------------------- | ---- | ---------- |
5917| uri | string | Yes  | URI of the file to be set as the album cover.|
5918| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
5919
5920**Error codes**
5921
5922For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5923
5924| ID| Error Message|
5925| -------- | ---------------------------------------- |
5926| 202      |  Called by non-system application.         |
5927| 401      |  if parameter is invalid.         |
5928| 13900012     | Permission denied.         |
5929| 13900020     | Invalid argument.         |
5930| 14000011       | System inner fail.         |
5931
5932**Example**
5933
5934```ts
5935import dataSharePredicates from '@ohos.data.dataSharePredicates';
5936
5937async function example() {
5938  try {
5939    console.info('setCoverUriDemoCallback');
5940    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5941    let fetchOption: photoAccessHelper.FetchOptions = {
5942      fetchColumns: [],
5943      predicates: predicates
5944    };
5945    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5946    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5947    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
5948    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5949    album.setCoverUri(asset.uri, (err) => {
5950      if (err === undefined) {
5951        console.info('album setCoverUri successfully');
5952      } else {
5953        console.error('album setCoverUri failed with error: ' + err);
5954      }
5955    });
5956  } catch (err) {
5957    console.error('setCoverUriDemoCallback failed with error: ' + err);
5958  }
5959}
5960```
5961
5962### setCoverUri<sup>(deprecated)</sup>
5963
5964setCoverUri(uri: string): Promise&lt;void&gt;
5965
5966Sets the album cover. This API uses a promise to return the result.
5967
5968> **NOTE**
5969>
5970> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.setCoverUri](#setcoveruri11) instead.
5971
5972> **NOTE**<br>This API can be used to set the user album cover, but not the system album cover.
5973
5974**System API**: This is a system API.
5975
5976**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
5977
5978**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5979
5980**Parameters**
5981
5982| Name  | Type                     | Mandatory| Description      |
5983| -------- | ------------------------- | ---- | ---------- |
5984| uri | string | Yes  | URI of the file to be set as the album cover.|
5985
5986**Return value**
5987
5988| Type                                   | Description             |
5989| --------------------------------------- | ----------------- |
5990|Promise&lt;void&gt; | Promise that returns no value.|
5991
5992**Error codes**
5993
5994For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
5995
5996| ID| Error Message|
5997| -------- | ---------------------------------------- |
5998| 202      |  Called by non-system application.         |
5999| 401      |  if parameter is invalid.         |
6000| 13900012     | Permission denied.         |
6001| 13900020     | Invalid argument.         |
6002| 14000011       | System inner fail.         |
6003**Example**
6004
6005```ts
6006import dataSharePredicates from '@ohos.data.dataSharePredicates';
6007import { BusinessError } from '@ohos.base';
6008
6009async function example() {
6010  try {
6011    console.info('setCoverUriDemoPromise');
6012    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6013    let fetchOption: photoAccessHelper.FetchOptions = {
6014      fetchColumns: [],
6015      predicates: predicates
6016    };
6017    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
6018    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6019    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
6020    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
6021    album.setCoverUri(asset.uri).then(() => {
6022      console.info('album setCoverUri successfully');
6023    }).catch((err: BusinessError) => {
6024      console.error('album setCoverUri failed with error: ' + err);
6025    });
6026  } catch (err) {
6027    console.error('setCoverUriDemoPromise failed with error: ' + err);
6028  }
6029}
6030```
6031
6032## MediaAssetEditData<sup>11+</sup>
6033
6034Represents the edited media asset data.
6035
6036**System API**: This is a system API.
6037
6038**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6039
6040### Attributes
6041
6042| Name          | Type   | Readable  | Writable | Description  |
6043| ------------ | ------ | ---- | ---- | ------- |
6044| compatibleFormat | string | Yes   | Yes   | Format of the edited data.   |
6045| formatVersion | string | Yes   | Yes  | Version of the data format.   |
6046| data | string | Yes   | Yes  | Content edited.   |
6047
6048### constructor<sup>11+</sup>
6049
6050constructor(compatibleFormat: string, formatVersion: string)
6051
6052Constructor.
6053
6054**System API**: This is a system API.
6055
6056**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6057
6058**Parameters**
6059
6060| Name  | Type                     | Mandatory| Description      |
6061| -------- | ------------------------- | ---- | ---------- |
6062| compatibleFormat | string | Yes  | Format of the edited data.|
6063| formatVersion | string | Yes  | Version of the data format.|
6064
6065**Error codes**
6066
6067For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6068
6069| ID| Error Message|
6070| -------- | ---------------------------------------- |
6071| 202      |  Called by non-system application.         |
6072| 401      |  if parameter is invalid.         |
6073| 14000011       | System inner fail.          |
6074
6075**Example**
6076
6077```ts
6078let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0');
6079```
6080
6081## MediaAssetChangeRequest<sup>11+</sup>
6082
6083Represents a media asset change request.
6084
6085**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6086
6087### constructor<sup>11+</sup>
6088
6089constructor(asset: PhotoAsset)
6090
6091Constructor.
6092
6093**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6094
6095**Parameters**
6096
6097| Name  | Type                     | Mandatory| Description      |
6098| -------- | ------------------------- | ---- | ---------- |
6099| asset | [PhotoAsset](#photoasset) | Yes  | Assets to change.|
6100
6101**Error codes**
6102
6103For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6104
6105| ID| Error Message|
6106| -------- | ---------------------------------------- |
6107| 401      |  if parameter is invalid.         |
6108| 14000011       | System inner fail.          |
6109
6110**Example**
6111
6112```ts
6113import dataSharePredicates from '@ohos.data.dataSharePredicates';
6114
6115async function example() {
6116  console.info('MediaAssetChangeRequest constructorDemo');
6117  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6118  let fetchOptions: photoAccessHelper.FetchOptions = {
6119    fetchColumns: [],
6120    predicates: predicates
6121  };
6122  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
6123  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
6124  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(photoAsset);
6125}
6126```
6127
6128### createImageAssetRequest<sup>11+</sup>
6129
6130static createImageAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
6131
6132Creates an image asset change request.
6133
6134The data source of the asset is specified by [fileUri][FileUri](js-apis-file-fileuri.md).
6135
6136**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6137
6138**Parameters**
6139
6140| Name | Type   | Mandatory| Description                      |
6141| ------- | ------- | ---- | -------------------------- |
6142| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6143| fileUri | string | Yes  | Data source of the image asset, which is specified by a URI in the application sandbox directory.|
6144
6145**Return value**
6146
6147| Type                                   | Description             |
6148| --------------------------------------- | ----------------- |
6149| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
6150
6151**Error codes**
6152
6153For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6154
6155| ID| Error Message|
6156| -------- | ---------------------------------------- |
6157| 401   | if parameter is invalid.         |
6158| 13900002   | No such file.         |
6159| 14000011   | System inner fail.        |
6160
6161**Example**
6162
6163```ts
6164async function example() {
6165  console.info('createImageAssetRequestDemo');
6166  try {
6167    // Ensure that the asset specified by fileUri exists.
6168    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6169    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
6170    await phAccessHelper.applyChanges(assetChangeRequest);
6171    console.info('apply createImageAssetRequest successfully');
6172  } catch (err) {
6173    console.error('createImageAssetRequestDemo failed with error: ' + err);
6174  }
6175}
6176```
6177
6178### createVideoAssetRequest<sup>11+</sup>
6179
6180static createVideoAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
6181
6182Creates a video asset change request.
6183
6184The data source of the asset is specified by [fileUri][FileUri](js-apis-file-fileuri.md).
6185
6186**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6187
6188**Parameters**
6189
6190| Name | Type   | Mandatory| Description                      |
6191| ------- | ------- | ---- | -------------------------- |
6192| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6193| fileUri | string | Yes  | Data source of the video asset, which is specified by a URI in the application sandbox directory.|
6194
6195**Return value**
6196
6197| Type                                   | Description             |
6198| --------------------------------------- | ----------------- |
6199| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
6200
6201**Error codes**
6202
6203For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6204
6205| ID| Error Message|
6206| -------- | ---------------------------------------- |
6207| 401   | if parameter is invalid.         |
6208| 13900002   | No such file.         |
6209| 14000011   | System inner fail.        |
6210
6211**Example**
6212
6213```ts
6214async function example() {
6215  console.info('createVideoAssetRequestDemo');
6216  try {
6217    // Ensure that the asset specified by fileUri exists.
6218    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
6219    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createVideoAssetRequest(context, fileUri);
6220    await phAccessHelper.applyChanges(assetChangeRequest);
6221    console.info('apply createVideoAssetRequest successfully');
6222  } catch (err) {
6223    console.error('createVideoAssetRequestDemo failed with error: ' + err);
6224  }
6225}
6226```
6227
6228### createAssetRequest<sup>11+</sup>
6229
6230static createAssetRequest(context: Context, displayName: string, options?: PhotoCreateOptions): MediaAssetChangeRequest
6231
6232Creates an asset change request based on a file name.
6233
6234The file name must comply with the following specifications:
6235- The file name must contain a valid file name and an image or video file name extension.
6236- The file name cannot exceed 255 characters.
6237- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
6238
6239**System API**: This is a system API.
6240
6241**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6242
6243**Parameters**
6244
6245| Name | Type   | Mandatory| Description                      |
6246| ------- | ------- | ---- | -------------------------- |
6247| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6248| displayName  | string        | Yes  | File name of the image or video to create.             |
6249| options  | [PhotoCreateOptions](#photocreateoptions)        | No  | Options for creating an image or video asset.             |
6250
6251**Return value**
6252
6253| Type                                   | Description             |
6254| --------------------------------------- | ----------------- |
6255| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
6256
6257**Error codes**
6258
6259For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6260
6261| ID| Error Message|
6262| -------- | ---------------------------------------- |
6263| 202   |  Called by non-system application.         |
6264| 401      |  if parameter is invalid.         |
6265| 14000001      | Invalid display name.         |
6266| 14000011       | System inner fail.         |
6267
6268**Example**
6269
6270```ts
6271async function example() {
6272  console.info('createAssetRequestDemo');
6273  try {
6274    let testFileName: string = 'testFile' + Date.now() + '.jpg';
6275    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, testFileName);
6276    // Ensure that the asset specified by fileUri exists.
6277    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6278    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
6279    await phAccessHelper.applyChanges(assetChangeRequest);
6280    console.info('apply createAssetRequest successfully');
6281  } catch (err) {
6282    console.error('createAssetRequestDemo failed with error: ' + err);
6283  }
6284}
6285```
6286
6287### createAssetRequest<sup>11+</sup>
6288
6289static createAssetRequest(context: Context, photoType: PhotoType, extension: string, options?: CreateOptions): MediaAssetChangeRequest
6290
6291Create an asset change request based on the file type and filename extension.
6292
6293**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6294
6295**Parameters**
6296
6297| Name | Type   | Mandatory| Description                      |
6298| ------- | ------- | ---- | -------------------------- |
6299| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6300| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
6301| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
6302| options  | [CreateOptions](#createoptions)        | Yes  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
6303
6304**Return value**
6305
6306| Type                                   | Description             |
6307| --------------------------------------- | ----------------- |
6308| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
6309
6310**Error codes**
6311
6312For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6313
6314| ID| Error Message|
6315| -------- | ---------------------------------------- |
6316| 401      |  if parameter is invalid.         |
6317| 14000011       | System inner fail.         |
6318
6319**Example**
6320
6321```ts
6322async function example() {
6323  console.info('createAssetRequestDemo');
6324  try {
6325    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
6326    let extension: string = 'jpg';
6327    let options: photoAccessHelper.CreateOptions = {
6328      title: 'testPhoto'
6329    }
6330    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension, options);
6331    // Ensure that the asset specified by fileUri exists.
6332    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6333    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
6334    await phAccessHelper.applyChanges(assetChangeRequest);
6335    console.info('apply createAssetRequest successfully');
6336  } catch (err) {
6337    console.error('createAssetRequestDemo failed with error: ' + err);
6338  }
6339}
6340```
6341
6342### deleteAssets<sup>11+</sup>
6343
6344static deleteAssets(context: Context, assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
6345
6346Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
6347
6348**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
6349
6350**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6351
6352**Parameters**
6353
6354| Name | Type   | Mandatory| Description                      |
6355| ------- | ------- | ---- | -------------------------- |
6356| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6357| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Media assets to delete.|
6358
6359**Return value**
6360
6361| Type                                   | Description             |
6362| --------------------------------------- | ----------------- |
6363| Promise&lt;void&gt;| Promise that returns no value.|
6364
6365**Error codes**
6366
6367For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6368
6369| ID| Error Message|
6370| -------- | ---------------------------------------- |
6371| 201      |  Permission denied.         |
6372| 401      |  if parameter is invalid.   |
6373| 14000011 |  System inner fail.         |
6374
6375**Example**
6376
6377```ts
6378import dataSharePredicates from '@ohos.data.dataSharePredicates';
6379
6380async function example() {
6381  console.info('deleteAssetsDemo');
6382  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6383  let fetchOptions: photoAccessHelper.FetchOptions = {
6384    fetchColumns: [],
6385    predicates: predicates
6386  };
6387  try {
6388    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
6389    let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
6390    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, photoAssetList);
6391    console.info('deleteAssets successfully');
6392  } catch (err) {
6393    console.error('deleteAssetsDemo failed with error: ' + err);
6394  }
6395}
6396```
6397
6398### deleteAssets<sup>11+</sup>
6399
6400static deleteAssets(context: Context, uriList: Array&lt;string&gt;): Promise&lt;void&gt;
6401
6402Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
6403
6404**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
6405
6406**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6407
6408**Parameters**
6409
6410| Name | Type   | Mandatory| Description                      |
6411| ------- | ------- | ---- | -------------------------- |
6412| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
6413| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete.|
6414
6415**Return value**
6416
6417| Type                                   | Description             |
6418| --------------------------------------- | ----------------- |
6419| Promise&lt;void&gt;| Promise that returns no value.|
6420
6421**Error codes**
6422
6423For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6424
6425| ID| Error Message|
6426| -------- | ---------------------------------------- |
6427| 201      |  Permission denied.         |
6428| 401      |  if parameter is invalid.   |
6429| 14000002 |  Invalid asset uri.         |
6430| 14000011 |  System inner fail.         |
6431
6432**Example**
6433
6434```ts
6435import dataSharePredicates from '@ohos.data.dataSharePredicates';
6436
6437async function example() {
6438  console.info('deleteAssetsDemo');
6439  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6440  let fetchOptions: photoAccessHelper.FetchOptions = {
6441    fetchColumns: [],
6442    predicates: predicates
6443  };
6444  try {
6445    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
6446    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
6447    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [asset.uri]);
6448    console.info('deleteAssets successfully');
6449  } catch (err) {
6450    console.error('deleteAssetsDemo failed with error: ' + err);
6451  }
6452}
6453```
6454
6455### getAsset<sup>11+</sup>
6456
6457getAsset(): PhotoAsset
6458
6459Obtains the asset in this asset change request.
6460
6461**NOTE**<br>For the change request used to create an asset, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
6462
6463**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6464
6465**Return value**
6466
6467| Type                                   | Description             |
6468| --------------------------------------- | ----------------- |
6469| [PhotoAsset](#photoasset) | Asset obtained.|
6470
6471**Error codes**
6472
6473For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6474
6475| ID| Error Message|
6476| -------- | ---------------------------------------- |
6477| 401      |  if parameter is invalid.   |
6478| 14000011 |  System inner fail.         |
6479
6480**Example**
6481
6482```ts
6483async function example() {
6484  console.info('getAssetDemo');
6485  try {
6486    // Ensure that the asset specified by fileUri exists.
6487    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6488    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
6489    await phAccessHelper.applyChanges(assetChangeRequest);
6490    let asset: photoAccessHelper.PhotoAsset = assetChangeRequest.getAsset();
6491    console.info('create asset successfully with uri = ' + asset.uri);
6492  } catch (err) {
6493    console.error('getAssetDemo failed with error: ' + err);
6494  }
6495}
6496```
6497
6498### setFavorite<sup>11+</sup>
6499
6500setFavorite(favoriteState: boolean): void
6501
6502Favorites or unfavorites this file.
6503
6504**System API**: This is a system API.
6505
6506**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6507
6508**Parameters**
6509
6510| Name       | Type     | Mandatory  | Description                                |
6511| ---------- | ------- | ---- | ---------------------------------- |
6512| favoriteState | boolean | Yes   | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
6513
6514**Error codes**
6515
6516For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6517
6518| ID| Error Message|
6519| -------- | ---------------------------------------- |
6520| 202        |  Called by non-system application.         |
6521| 401       |  if parameter is invalid.         |
6522| 14000011       | System inner fail.         |
6523
6524**Example**
6525
6526```ts
6527import dataSharePredicates from '@ohos.data.dataSharePredicates';
6528import { BusinessError } from '@ohos.base';
6529
6530async function example() {
6531  console.info('setFavoriteDemo');
6532  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6533  let fetchOption: photoAccessHelper.FetchOptions = {
6534    fetchColumns: [],
6535    predicates: predicates
6536  };
6537  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6538  let asset = await fetchResult.getFirstObject();
6539  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6540  assetChangeRequest.setFavorite(true);
6541  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
6542    console.info('apply setFavorite successfully');
6543  }).catch((err: BusinessError) => {
6544    console.error('apply setFavorite failed with error:' + err);
6545  });
6546}
6547```
6548
6549### setHidden<sup>11+</sup>
6550
6551setHidden(hiddenState: boolean): void
6552
6553Hides this file.
6554
6555**System API**: This is a system API.
6556
6557**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6558
6559**Parameters**
6560
6561| Name       | Type     | Mandatory  | Description                                |
6562| ---------- | ------- | ---- | ---------------------------------- |
6563| hiddenState | boolean  | Yes   | Whether to hide the file. The value **true** means to hide the file; the value **false** means the opposite.|
6564
6565**Error codes**
6566
6567For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6568
6569| ID| Error Message|
6570| -------- | ---------------------------------------- |
6571| 202        |  Called by non-system application.         |
6572| 401       |  if parameter is invalid.         |
6573| 14000011       | System inner fail.         |
6574
6575**Example**
6576
6577```ts
6578import dataSharePredicates from '@ohos.data.dataSharePredicates';
6579import { BusinessError } from '@ohos.base';
6580
6581async function example() {
6582  console.info('setHiddenDemo');
6583  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6584  let fetchOption: photoAccessHelper.FetchOptions = {
6585    fetchColumns: [],
6586    predicates: predicates
6587  };
6588  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6589  let asset = await fetchResult.getFirstObject();
6590  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6591  assetChangeRequest.setHidden(true);
6592  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
6593    console.info('apply setHidden successfully');
6594  }).catch((err: BusinessError) => {
6595    console.error('apply setHidden failed with error:' + err);
6596  });
6597}
6598```
6599
6600### setUserComment<sup>11+</sup>
6601
6602setUserComment(userComment: string): void
6603
6604Sets the user comment information of this media asset.
6605
6606**System API**: This is a system API.
6607
6608**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6609
6610**Parameters**
6611
6612| Name       | Type     | Mandatory  | Description                                |
6613| ---------- | ------- | ---- | ---------------------------------- |
6614| userComment | string | Yes  | Comment information to set, which cannot exceed 420 characters.|
6615
6616**Error codes**
6617
6618For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6619
6620| ID| Error Message|
6621| -------- | ---------------------------------------- |
6622| 202        |  Called by non-system application.         |
6623| 401       |  if parameter is invalid.         |
6624| 14000011       | System inner fail.         |
6625
6626**Example**
6627
6628```ts
6629import dataSharePredicates from '@ohos.data.dataSharePredicates';
6630import { BusinessError } from '@ohos.base';
6631
6632async function example() {
6633  console.info('setUserCommentDemo');
6634  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6635  let fetchOption: photoAccessHelper.FetchOptions = {
6636    fetchColumns: [],
6637    predicates: predicates
6638  };
6639  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6640  let asset = await fetchResult.getFirstObject();
6641  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6642  let userComment: string = 'test_set_user_comment';
6643  assetChangeRequest.setUserComment(userComment);
6644  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
6645    console.info('apply setUserComment successfully');
6646  }).catch((err: BusinessError) => {
6647    console.error('apply setUserComment failed with error:' + err);
6648  });
6649}
6650```
6651
6652### setTitle<sup>11+</sup>
6653
6654setTitle(title: string): void
6655
6656Sets the media asset title.
6657
6658**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6659
6660**Parameters**
6661
6662| Name       | Type     | Mandatory  | Description                                |
6663| ---------- | ------- | ---- | ---------------------------------- |
6664| title | string | Yes  | Title to set.|
6665
6666The title must comply with the following specifications:
6667- The title should not contain the filename extension.
6668- It cannot exceed 255 characters.
6669- The title cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
6670
6671**Error codes**
6672
6673For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6674
6675| ID| Error Message|
6676| -------- | ---------------------------------------- |
6677| 401       |  if parameter is invalid.         |
6678| 14000011       | System inner fail.         |
6679
6680**Example**
6681
6682```ts
6683import dataSharePredicates from '@ohos.data.dataSharePredicates';
6684import { BusinessError } from '@ohos.base';
6685
6686async function example() {
6687  console.info('setTitleDemo');
6688  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6689  let fetchOption: photoAccessHelper.FetchOptions = {
6690    fetchColumns: [],
6691    predicates: predicates
6692  };
6693  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6694  let asset = await fetchResult.getFirstObject();
6695  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6696  let newTitle: string = 'newTitle';
6697  assetChangeRequest.setTitle(newTitle);
6698  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
6699    console.info('apply setTitle successfully');
6700  }).catch((err: BusinessError) => {
6701    console.error('apply setTitle failed with error:' + err);
6702  });
6703}
6704```
6705
6706### setEditData<sup>11+</sup>
6707
6708setEditData(editData: MediaAssetEditData): void
6709
6710Saves the edited data of an asset.
6711
6712**System API**: This is a system API.
6713
6714**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6715
6716**Parameters**
6717
6718| Name       | Type     | Mandatory  | Description                                |
6719| ---------- | ------- | ---- | ---------------------------------- |
6720| editData | (MediaAssetEditData)[#mediaasseteditdata11] | Yes  | Edited data to save.|
6721
6722**Error codes**
6723
6724For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6725
6726| ID| Error Message|
6727| -------- | ---------------------------------------- |
6728| 202        |  Called by non-system application.         |
6729| 401       |  if parameter is invalid.         |
6730| 14000011       | System inner fail.         |
6731
6732**Example**
6733
6734```ts
6735import dataSharePredicates from '@ohos.data.dataSharePredicates';
6736import { BusinessError } from '@ohos.base';
6737
6738async function example() {
6739  console.info('setEditDataDemo');
6740  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6741  let fetchOption: photoAccessHelper.FetchOptions = {
6742    fetchColumns: [],
6743    predicates: predicates
6744  };
6745  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6746  let asset = await fetchResult.getFirstObject();
6747  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6748
6749  let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0');
6750  let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6751  assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
6752  assetEditData.data = '123456';
6753  assetChangeRequest.setEditData(assetEditData);
6754  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
6755    console.info('apply setEditData successfully');
6756  }).catch((err: BusinessError) => {
6757    console.error('apply setEditData failed with error:' + err);
6758  });
6759}
6760```
6761
6762### getWriteCacheHandler<sup>11+</sup>
6763
6764getWriteCacheHandler(): Promise&lt;number&gt;
6765
6766Obtains the write handle of a temporary file.
6767
6768**NOTE**<br>For the same asset change request, this API cannot be repeatedly called after a temporary file write handle is successfully obtained.
6769
6770**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6771
6772**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
6773
6774**Return value**
6775
6776| Type                                   | Description             |
6777| --------------------------------------- | ----------------- |
6778| Promise&lt;number&gt; | Promise used to return the write handle obtained.|
6779
6780**Error codes**
6781
6782For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6783
6784| ID| Error Message|
6785| -------- | ---------------------------------------- |
6786| 201   | Permission denied.        |
6787| 401      |  if parameter is invalid.   |
6788| 14000011 |  System inner fail.         |
6789| 14000016 |  Operation Not Support.     |
6790
6791**Example**
6792
6793```ts
6794import fs from '@ohos.file.fs';
6795
6796async function example() {
6797  console.info('getWriteCacheHandlerDemo');
6798  try {
6799    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.VIDEO;
6800    let extension: string = 'mp4';
6801    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
6802    let fd: number = await assetChangeRequest.getWriteCacheHandler();
6803    console.info('getWriteCacheHandler successfully');
6804    // write date into fd
6805    await fs.close(fd);
6806    await phAccessHelper.applyChanges(assetChangeRequest);
6807  } catch (err) {
6808    console.error('getWriteCacheHandlerDemo failed with error: ' + err);
6809  }
6810}
6811```
6812
6813### addResource<sup>11+</sup>
6814
6815addResource(type: ResourceType, fileUri: string): void
6816
6817Adds resources to the application sandbox directory using **fileUri**.
6818
6819**NOTE**<br>For the same asset change request, this API cannot be repeatedly called after resources are successfully added.
6820
6821**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6822
6823**Parameters**
6824
6825| Name | Type   | Mandatory| Description                      |
6826| ------- | ------- | ---- | -------------------------- |
6827| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
6828| fileUri | string | Yes  | Data source of the resource to be added, which is specified by a URI in the application sandbox directory.|
6829
6830**Error codes**
6831
6832For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6833
6834| ID| Error Message|
6835| -------- | ---------------------------------------- |
6836| 401      |  if parameter is invalid.   |
6837| 13900002      |  No such file.   |
6838| 14000011 |  System inner fail.         |
6839| 14000016 |  Operation Not Support.     |
6840
6841**Example**
6842
6843```ts
6844async function example() {
6845  console.info('addResourceByFileUriDemo');
6846  try {
6847    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
6848    let extension: string = 'jpg';
6849    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
6850    // Ensure that the asset specified by fileUri exists.
6851    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
6852    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
6853    await phAccessHelper.applyChanges(assetChangeRequest);
6854    console.info('addResourceByFileUri successfully');
6855  } catch (err) {
6856    console.error('addResourceByFileUriDemo failed with error: ' + err);
6857  }
6858}
6859```
6860
6861### addResource<sup>11+</sup>
6862
6863addResource(type: ResourceType, data: ArrayBuffer): void
6864
6865Adds resources using **ArrayBuffer** data.
6866
6867**NOTE**<br>For the same asset change request, this API cannot be repeatedly called after resources are successfully added.
6868
6869**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6870
6871**Parameters**
6872
6873| Name | Type   | Mandatory| Description                      |
6874| ------- | ------- | ---- | -------------------------- |
6875| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
6876| data | ArrayBuffer | Yes  | Data of the resource to add.|
6877
6878**Error codes**
6879
6880For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6881
6882| ID| Error Message|
6883| -------- | ---------------------------------------- |
6884| 401      |  if parameter is invalid.   |
6885| 14000011 |  System inner fail.         |
6886| 14000016 |  Operation Not Support.     |
6887
6888**Example**
6889
6890```ts
6891async function example() {
6892  console.info('addResourceByArrayBufferDemo');
6893  try {
6894    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
6895    let extension: string = 'jpg';
6896    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
6897    let buffer: ArrayBuffer = new ArrayBuffer(2048);
6898    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, buffer);
6899    await phAccessHelper.applyChanges(assetChangeRequest);
6900    console.info('addResourceByArrayBuffer successfully');
6901  } catch (err) {
6902    console.error('addResourceByArrayBufferDemo failed with error: ' + err);
6903  }
6904}
6905```
6906
6907### addResource<sup>11+</sup>
6908
6909addResource(type: ResourceType, proxy: PhotoProxy): void
6910
6911Adds resources using **PhotoProxy** data.
6912
6913**NOTE**<br>For the same asset change request, this API cannot be repeatedly called after resources are successfully added.
6914
6915**System API**: This is a system API available only for camera applications.
6916
6917**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6918
6919**Parameters**
6920
6921| Name | Type                             | Mandatory| Description                  |
6922| ------- |---------------------------------| ---- |----------------------|
6923| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.           |
6924| proxy | [PhotoProxy](#photoproxy11)     | Yes  | **PhotoProxy** data of the resource to add.|
6925
6926**Error codes**
6927
6928For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6929
6930| ID   | Error Message                             |
6931|----------|-----------------------------------|
6932| 202      | Called by non-system application. |
6933| 401      | if parameter is invalid.          |
6934| 14000011 | System inner fail.                |
6935| 14000016 | Operation Not Support.            |
6936
6937**Example**
6938
6939```ts
6940async function example() {
6941  console.info('addResourceByPhotoProxyDemo');
6942  try {
6943    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
6944    let extension: string = 'jpg';
6945    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
6946    let photoProxy: PhotoProxy;
6947    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, photoProxy);
6948    await phAccessHelper.applyChanges(assetChangeRequest);
6949    console.info('addResourceByPhotoProxy successfully');
6950  } catch (err) {
6951    console.error('addResourceByPhotoProxyDemo failed with error: ' + err);
6952  }
6953}
6954```
6955
6956### setLocation<sup>11+</sup>
6957
6958setLocation(longitude: number, latitude: number): void
6959
6960Sets location information.
6961
6962**System API**: This is a system API.
6963
6964**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
6965
6966**Parameters**
6967
6968| Name | Type         | Mandatory| Description   |
6969| ------- |-------------| ---- |-------|
6970| longitude | number      | Yes  | Longitude.|
6971| latitude | number | Yes  | Latitude.  |
6972
6973**Error codes**
6974
6975For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
6976
6977| ID| Error Message|
6978| -------- | ---------------------------------------- |
6979| 202      | Called by non-system application. |
6980| 401      |  if parameter is invalid.   |
6981| 14000011 |  System inner fail.         |
6982
6983**Example**
6984
6985```ts
6986import dataSharePredicates from '@ohos.data.dataSharePredicates';
6987import { BusinessError } from '@ohos.base';
6988
6989async function example() {
6990  console.info('setLocationDemo');
6991  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6992  let fetchOption: photoAccessHelper.FetchOptions = {
6993    fetchColumns: [],
6994    predicates: predicates
6995  };
6996  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
6997  let asset = await fetchResult.getFirstObject();
6998  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6999  assetChangeRequest.setLocation(120.52, 30.40);
7000  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
7001    console.info('apply setLocation successfully');
7002  }).catch((err: BusinessError) => {
7003    console.error('apply setLocation failed with error:' + err);
7004  });
7005}
7006```
7007
7008## MediaAssetsChangeRequest<sup>11+</sup>
7009
7010Represents a request for changing assets.
7011
7012**System API**: This is a system API.
7013
7014**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7015
7016### constructor<sup>11+</sup>
7017
7018constructor(assets: Array&lt;PhotoAsset&gt;)
7019
7020Constructor.
7021
7022**System API**: This is a system API.
7023
7024**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7025
7026**Parameters**
7027
7028| Name  | Type                     | Mandatory| Description      |
7029| -------- | ------------------------- | ---- | ---------- |
7030| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to change.|
7031
7032**Error codes**
7033
7034For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7035
7036| ID| Error Message|
7037| -------- | ---------------------------------------- |
7038| 202        |  Called by non-system application.   |
7039| 401      |  if parameter is invalid.         |
7040| 14000011       | System inner fail.          |
7041
7042**Example**
7043
7044```ts
7045import dataSharePredicates from '@ohos.data.dataSharePredicates';
7046
7047async function example() {
7048  console.info('MediaAssetsChangeRequest constructorDemo');
7049  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7050  let fetchOption: photoAccessHelper.FetchOptions = {
7051    fetchColumns: [],
7052    predicates: predicates
7053  };
7054  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
7055  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
7056  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
7057}
7058```
7059
7060### setFavorite<sup>11+</sup>
7061
7062setFavorite(favoriteState: boolean): void
7063
7064Favorites or unfavorites this file.
7065
7066**System API**: This is a system API.
7067
7068**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7069
7070**Parameters**
7071
7072| Name       | Type     | Mandatory  | Description                                |
7073| ---------- | ------- | ---- | ---------------------------------- |
7074| favoriteState | boolean | Yes   | Operation to perform. The value **true** means to favorite the file, and **false** means the opposite.|
7075
7076**Error codes**
7077
7078For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7079
7080| ID| Error Message|
7081| -------- | ---------------------------------------- |
7082| 202        |  Called by non-system application.         |
7083| 401       |  if parameter is invalid.         |
7084| 14000011       | System inner fail.         |
7085
7086**Example**
7087
7088```ts
7089import dataSharePredicates from '@ohos.data.dataSharePredicates';
7090import { BusinessError } from '@ohos.base';
7091
7092async function example() {
7093  console.info('setFavoriteDemo');
7094  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7095  let fetchOption: photoAccessHelper.FetchOptions = {
7096    fetchColumns: [],
7097    predicates: predicates
7098  };
7099  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
7100  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
7101  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
7102  assetsChangeRequest.setFavorite(true);
7103  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
7104    console.info('apply setFavorite successfully');
7105  }).catch((err: BusinessError) => {
7106    console.error('apply setFavorite failed with error:' + err);
7107  });
7108}
7109```
7110
7111### setHidden<sup>11+</sup>
7112
7113setHidden(hiddenState: boolean): void
7114
7115Hides this file.
7116
7117**System API**: This is a system API.
7118
7119**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7120
7121**Parameters**
7122
7123| Name       | Type     | Mandatory  | Description                                |
7124| ---------- | ------- | ---- | ---------------------------------- |
7125| hiddenState | boolean  | Yes   | Whether to hide the file. The value **true** means to hide the file; the value **false** means the opposite.|
7126
7127**Error codes**
7128
7129For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7130
7131| ID| Error Message|
7132| -------- | ---------------------------------------- |
7133| 202        |  Called by non-system application.         |
7134| 401       |  if parameter is invalid.         |
7135| 14000011       | System inner fail.         |
7136
7137**Example**
7138
7139```ts
7140import dataSharePredicates from '@ohos.data.dataSharePredicates';
7141import { BusinessError } from '@ohos.base';
7142
7143async function example() {
7144  console.info('setHiddenDemo');
7145  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7146  let fetchOption: photoAccessHelper.FetchOptions = {
7147    fetchColumns: [],
7148    predicates: predicates
7149  };
7150  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
7151  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
7152  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
7153  assetsChangeRequest.setHidden(true);
7154  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
7155    console.info('apply setHidden successfully');
7156  }).catch((err: BusinessError) => {
7157    console.error('apply setHidden failed with error:' + err);
7158  });
7159}
7160```
7161
7162### setUserComment<sup>11+</sup>
7163
7164setUserComment(userComment: string): void
7165
7166Sets the user comment information of this media asset.
7167
7168**System API**: This is a system API.
7169
7170**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7171
7172**Parameters**
7173
7174| Name       | Type     | Mandatory  | Description                                |
7175| ---------- | ------- | ---- | ---------------------------------- |
7176| userComment | string | Yes  | Comment information to set, which cannot exceed 420 characters.|
7177
7178**Error codes**
7179
7180For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7181
7182| ID| Error Message|
7183| -------- | ---------------------------------------- |
7184| 202        |  Called by non-system application.         |
7185| 401       |  if parameter is invalid.         |
7186| 14000011       | System inner fail.         |
7187
7188**Example**
7189
7190```ts
7191import dataSharePredicates from '@ohos.data.dataSharePredicates';
7192import { BusinessError } from '@ohos.base';
7193
7194async function example() {
7195  console.info('setUserCommentDemo');
7196  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7197  let fetchOption: photoAccessHelper.FetchOptions = {
7198    fetchColumns: [],
7199    predicates: predicates
7200  };
7201  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
7202  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
7203  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
7204  assetsChangeRequest.setUserComment('test_set_user_comment');
7205  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
7206    console.info('apply setUserComment successfully');
7207  }).catch((err: BusinessError) => {
7208    console.error('apply setUserComment failed with error:' + err);
7209  });
7210}
7211```
7212
7213## MediaAlbumChangeRequest<sup>11+</sup>
7214
7215Provides APIs for managing the media album change request.
7216
7217**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7218
7219### constructor<sup>11+</sup>
7220
7221constructor(album: Album)
7222
7223Constructor.
7224
7225**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7226
7227**Parameters**
7228
7229| Name  | Type                     | Mandatory| Description      |
7230| -------- | ------------------------- | ---- | ---------- |
7231| album | [Album](#album) | Yes  | Album to change.|
7232
7233**Error codes**
7234
7235For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7236
7237| ID| Error Message|
7238| -------- | ---------------------------------------- |
7239| 401      |  if parameter is invalid.         |
7240| 14000011       | System inner fail.          |
7241
7242**Example**
7243
7244```ts
7245import dataSharePredicates from '@ohos.data.dataSharePredicates';
7246
7247async function example() {
7248  console.info('MediaAlbumChangeRequest constructorDemo');
7249  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7250  let fetchOptions: photoAccessHelper.FetchOptions = {
7251    fetchColumns: [],
7252    predicates: predicates
7253  };
7254  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
7255  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7256  let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7257}
7258```
7259
7260### createAlbumRequest<sup>11+</sup>
7261
7262static createAlbumRequest(context: Context, name: string): MediaAlbumChangeRequest
7263
7264Creates a **MediaAlbumChangeRequest** instance.
7265
7266The album name must comply with the following specifications:
7267- The album name cannot exceed 255 characters.
7268- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
7269- The album name is case-insensitive.
7270- Duplicate album names are not allowed.
7271
7272**System API**: This is a system API.
7273
7274**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7275
7276**Parameters**
7277
7278| Name | Type   | Mandatory| Description                      |
7279| ------- | ------- | ---- | -------------------------- |
7280| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
7281| name | string | Yes  | Name of the album to create. |
7282
7283**Return value**
7284
7285| Type                                   | Description             |
7286| --------------------------------------- | ----------------- |
7287| [MediaAlbumChangeRequest](#mediaalbumchangerequest11) | **MediaAlbumChangeRequest** instance created.|
7288
7289**Error codes**
7290
7291For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7292
7293| ID| Error Message|
7294| -------- | ---------------------------------------- |
7295| 202   |  Called by non-system application.         |
7296| 401   | if parameter is invalid.         |
7297| 14000011   | System inner fail.        |
7298
7299**Example**
7300
7301```ts
7302async function example() {
7303  console.info('createAlbumRequestDemo');
7304  try {
7305    let albumName: string = 'newAlbumName' + new Date().getTime();
7306    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = photoAccessHelper.MediaAlbumChangeRequest.createAlbumRequest(context, albumName);
7307    await phAccessHelper.applyChanges(albumChangeRequest);
7308    console.info('apply createAlbumRequest successfully');
7309  } catch (err) {
7310    console.error('createAlbumRequestDemo failed with error: ' + err);
7311  }
7312}
7313```
7314
7315### deleteAlbums<sup>11+</sup>
7316
7317static deleteAlbums(context: Context, albums: Array&lt;Album&gt;): Promise&lt;void&gt;
7318
7319Deletes albums. This API uses a promise to return the result.
7320
7321Ensure that the albums to be deleted exist. Only user albums can be deleted.
7322
7323**System API**: This is a system API.
7324
7325**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
7326
7327**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7328
7329**Parameters**
7330
7331| Name | Type   | Mandatory| Description                      |
7332| ------- | ------- | ---- | -------------------------- |
7333| context | [Context](js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
7334| albums  |  Array&lt;[Album](#album)&gt;          | Yes  | Albums to delete.        |
7335
7336**Return value**
7337
7338| Type                                   | Description             |
7339| --------------------------------------- | ----------------- |
7340| Promise&lt;void&gt;| Promise that returns no value.|
7341
7342**Error codes**
7343
7344For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7345
7346| ID| Error Message|
7347| -------- | ---------------------------------------- |
7348| 201      |  Permission denied.         |
7349| 202   |  Called by non-system application.  |
7350| 401      |  if parameter is invalid.   |
7351| 14000011 |  System inner fail.         |
7352
7353**Example**
7354
7355```ts
7356import dataSharePredicates from '@ohos.data.dataSharePredicates';
7357
7358async function example() {
7359  console.info('deleteAlbumsDemo');
7360  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7361  let fetchOptions: photoAccessHelper.FetchOptions = {
7362    fetchColumns: [],
7363    predicates: predicates
7364  };
7365  try {
7366    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
7367    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7368    await photoAccessHelper.MediaAlbumChangeRequest.deleteAlbums(context, [album]);
7369    console.info('deleteAlbums successfully');
7370  } catch (err) {
7371    console.error('deleteAlbumsDemo failed with error: ' + err);
7372  }
7373}
7374```
7375
7376### getAlbum<sup>11+</sup>
7377
7378getAlbum(): Album
7379
7380Obtains the album in the current album change request.
7381
7382**NOTE**<br>For the change request for creating an album, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
7383
7384**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7385
7386**Return value**
7387
7388| Type                                   | Description             |
7389| --------------------------------------- | ----------------- |
7390| [Album](#album) | Album obtained.|
7391
7392**Error codes**
7393
7394For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7395
7396| ID| Error Message|
7397| -------- | ---------------------------------------- |
7398| 401      |  if parameter is invalid.   |
7399| 14000011 |  System inner fail.         |
7400
7401**Example**
7402
7403```ts
7404async function example() {
7405  console.info('getAlbumDemo');
7406  try {
7407    let albumName: string = 'newAlbumName' + new Date().getTime();
7408    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = photoAccessHelper.MediaAlbumChangeRequest.createAlbumRequest(context, albumName);
7409    await phAccessHelper.applyChanges(albumChangeRequest);
7410    let album: photoAccessHelper.Album = albumChangeRequest.getAlbum();
7411    console.info('create album successfully with uri = ' + album.albumUri);
7412  } catch (err) {
7413    console.error('getAlbumDemo failed with error: ' + err);
7414  }
7415}
7416```
7417
7418### setCoverUri<sup>11+</sup>
7419
7420setCoverUri(coverUri: string): void
7421
7422Sets the album cover.
7423
7424**System API**: This is a system API.
7425
7426**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7427
7428**Parameters**
7429
7430| Name       | Type     | Mandatory  | Description                                |
7431| ---------- | ------- | ---- | ---------------------------------- |
7432| coverUri | string | Yes  | URI of the file to be set as the album cover.|
7433
7434**Error codes**
7435
7436For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7437
7438| ID| Error Message|
7439| -------- | ---------------------------------------- |
7440| 202        |  Called by non-system application.         |
7441| 401       |  if parameter is invalid.         |
7442| 14000011       | System inner fail.         |
7443
7444**Example**
7445
7446```ts
7447import dataSharePredicates from '@ohos.data.dataSharePredicates';
7448
7449async function example() {
7450  console.info('setCoverUriDemo');
7451  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7452  let fetchOptions: photoAccessHelper.FetchOptions = {
7453    fetchColumns: [],
7454    predicates: predicates
7455  };
7456  try {
7457    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
7458    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7459    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
7460    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7461
7462    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7463    albumChangeRequest.setCoverUri(asset.uri);
7464    await phAccessHelper.applyChanges(albumChangeRequest);
7465    console.info('setCoverUri successfully');
7466  } catch (err) {
7467    console.error('setCoverUriDemo failed with error: ' + err);
7468  }
7469}
7470```
7471
7472### setAlbumName<sup>11+</sup>
7473
7474setAlbumName(name: string): void
7475
7476Sets the album name.
7477
7478The album name must comply with the following specifications:
7479- The album name cannot exceed 255 characters.
7480- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
7481- The album name is case-insensitive.
7482- Duplicate album names are not allowed.
7483
7484**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7485
7486**Parameters**
7487
7488| Name       | Type     | Mandatory  | Description                                |
7489| ---------- | ------- | ---- | ---------------------------------- |
7490| name | string | Yes  | Album name to set.|
7491
7492**Error codes**
7493
7494For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7495
7496| ID| Error Message|
7497| -------- | ---------------------------------------- |
7498| 401       |  if parameter is invalid.         |
7499| 14000011       | System inner fail.         |
7500
7501**Example**
7502
7503```ts
7504async function example() {
7505  console.info('setAlbumNameDemo');
7506  try {
7507    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
7508    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7509    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7510    let newAlbumName: string = 'newAlbumName' + new Date().getTime();
7511    albumChangeRequest.setAlbumName(newAlbumName);
7512    await phAccessHelper.applyChanges(albumChangeRequest);
7513    console.info('setAlbumName successfully');
7514  } catch (err) {
7515    console.error('setAlbumNameDemo failed with error: ' + err);
7516  }
7517}
7518```
7519
7520### addAssets<sup>11+</sup>
7521
7522addAssets(assets: Array&lt;PhotoAsset&gt;): void
7523
7524Add assets to the album.
7525
7526**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7527
7528**Parameters**
7529
7530| Name       | Type     | Mandatory  | Description                                |
7531| ---------- | ------- | ---- | ---------------------------------- |
7532| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to add.|
7533
7534**Error codes**
7535
7536For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7537
7538| ID| Error Message|
7539| -------- | ---------------------------------------- |
7540| 401       |  if parameter is invalid.         |
7541| 14000011       | System inner fail.         |
7542| 14000016 |  Operation Not Support.     |
7543
7544**Example**
7545
7546```ts
7547import dataSharePredicates from '@ohos.data.dataSharePredicates';
7548
7549async function example() {
7550  console.info('addAssetsDemo');
7551  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7552  let fetchOptions: photoAccessHelper.FetchOptions = {
7553    fetchColumns: [],
7554    predicates: predicates
7555  };
7556  try {
7557    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
7558    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7559    let albumName: string = 'newAlbumName' + new Date().getTime();
7560    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = photoAccessHelper.MediaAlbumChangeRequest.createAlbumRequest(context, albumName);
7561    albumChangeRequest.addAssets([asset]);
7562    await phAccessHelper.applyChanges(albumChangeRequest);
7563    console.info('addAssets successfully');
7564  } catch (err) {
7565    console.error('addAssetsDemo failed with error: ' + err);
7566  }
7567}
7568```
7569
7570### removeAssets<sup>11+</sup>
7571
7572removeAssets(assets: Array&lt;PhotoAsset&gt;): void
7573
7574Removes assets from the album.
7575
7576**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7577
7578**Parameters**
7579
7580| Name       | Type     | Mandatory  | Description                                |
7581| ---------- | ------- | ---- | ---------------------------------- |
7582| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to remove.|
7583
7584**Error codes**
7585
7586For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7587
7588| ID| Error Message|
7589| -------- | ---------------------------------------- |
7590| 401       |  if parameter is invalid.         |
7591| 14000011       | System inner fail.         |
7592| 14000016 |  Operation Not Support.     |
7593
7594**Example**
7595
7596```ts
7597import dataSharePredicates from '@ohos.data.dataSharePredicates';
7598
7599async function example() {
7600  console.info('removeAssetsDemo');
7601  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7602  let fetchOptions: photoAccessHelper.FetchOptions = {
7603    fetchColumns: [],
7604    predicates: predicates
7605  };
7606  try {
7607    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
7608    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7609    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
7610    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7611
7612    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7613    albumChangeRequest.removeAssets([asset]);
7614    await phAccessHelper.applyChanges(albumChangeRequest);
7615    console.info('removeAssets successfully');
7616  } catch (err) {
7617    console.error('removeAssetsDemo failed with error: ' + err);
7618  }
7619}
7620```
7621
7622### moveAssets<sup>11+</sup>
7623
7624moveAssets(assets: Array&lt;PhotoAsset&gt;, targetAlbum: Album): void
7625
7626Moves assets to another album.
7627
7628**System API**: This is a system API.
7629
7630**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7631
7632**Parameters**
7633
7634| Name       | Type     | Mandatory  | Description                                |
7635| ---------- | ------- | ---- | ---------------------------------- |
7636| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to move.|
7637| targetAlbum | Album | Yes  | Album to which the assets are to be moved.|
7638
7639**Error codes**
7640
7641For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7642
7643| ID| Error Message|
7644| -------- | ---------------------------------------- |
7645| 202      |  Called by non-system application.         |
7646| 401       |  if parameter is invalid.         |
7647| 14000011       | System inner fail.         |
7648| 14000016 |  Operation Not Support.     |
7649
7650**Example**
7651
7652```ts
7653import dataSharePredicates from '@ohos.data.dataSharePredicates';
7654
7655async function example() {
7656  console.info('moveAssetsDemo');
7657  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7658  let fetchOptions: photoAccessHelper.FetchOptions = {
7659    fetchColumns: [],
7660    predicates: predicates
7661  };
7662  try {
7663    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
7664    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7665    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
7666    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7667
7668    if (albumFetchResult.isAfterLast()) {
7669      console.error('lack of album to be moved into');
7670      return;
7671    }
7672    let nextAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject();
7673    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7674    albumChangeRequest.moveAssets([asset], nextAlbum);
7675    await phAccessHelper.applyChanges(albumChangeRequest);
7676    console.info('moveAssets successfully');
7677  } catch (err) {
7678    console.error('moveAssetsDemo failed with error: ' + err);
7679  }
7680}
7681```
7682
7683### recoverAssets<sup>11+</sup>
7684
7685recoverAssets(assets: Array&lt;PhotoAsset&gt;): void
7686
7687Recovers assets from the trash.
7688
7689**System API**: This is a system API.
7690
7691**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7692
7693**Parameters**
7694
7695| Name       | Type     | Mandatory  | Description                                |
7696| ---------- | ------- | ---- | ---------------------------------- |
7697| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to recover.|
7698
7699**Error codes**
7700
7701For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7702
7703| ID| Error Message|
7704| -------- | ---------------------------------------- |
7705| 202      |  Called by non-system application.         |
7706| 401       |  if parameter is invalid.         |
7707| 14000011       | System inner fail.         |
7708| 14000016 |  Operation Not Support.     |
7709
7710**Example**
7711
7712```ts
7713import dataSharePredicates from '@ohos.data.dataSharePredicates';
7714
7715async function example() {
7716  console.info('recoverAssetsDemo');
7717  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7718  let fetchOptions: photoAccessHelper.FetchOptions = {
7719    fetchColumns: [],
7720    predicates: predicates
7721  };
7722  try {
7723    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
7724    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7725    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
7726    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7727
7728    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7729    albumChangeRequest.recoverAssets([asset]);
7730    await phAccessHelper.applyChanges(albumChangeRequest);
7731    console.info('recoverAssets successfully');
7732  } catch (err) {
7733    console.error('recoverAssetsDemo failed with error: ' + err);
7734  }
7735}
7736```
7737
7738### deleteAssets<sup>11+</sup>
7739
7740deleteAssets(assets: Array&lt;PhotoAsset&gt;): void
7741
7742Permanently deletes assets from the trash.
7743
7744**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
7745
7746**System API**: This is a system API.
7747
7748**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7749
7750**Parameters**
7751
7752| Name       | Type     | Mandatory  | Description                                |
7753| ---------- | ------- | ---- | ---------------------------------- |
7754| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to be permanently deleted.|
7755
7756**Error codes**
7757
7758For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7759
7760| ID| Error Message|
7761| -------- | ---------------------------------------- |
7762| 202      |  Called by non-system application.         |
7763| 401       |  if parameter is invalid.         |
7764| 14000011       | System inner fail.         |
7765| 14000016 |  Operation Not Support.     |
7766
7767**Example**
7768
7769```ts
7770import dataSharePredicates from '@ohos.data.dataSharePredicates';
7771
7772async function example() {
7773  console.info('deleteAssetsPermanentlyDemo');
7774  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7775  let fetchOptions: photoAccessHelper.FetchOptions = {
7776    fetchColumns: [],
7777    predicates: predicates
7778  };
7779  try {
7780    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
7781    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
7782    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
7783    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
7784
7785    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7786    albumChangeRequest.deleteAssets([asset]);
7787    await phAccessHelper.applyChanges(albumChangeRequest);
7788    console.info('succeed to deleteAssets permanently');
7789  } catch (err) {
7790    console.error('deleteAssetsPermanentlyDemo failed with error: ' + err);
7791  }
7792}
7793```
7794
7795### setDisplayLevel<sup>11+</sup>
7796
7797setDisplayLevel(displayLevel: number): void
7798
7799Sets the display level of the portrait album.
7800
7801**System API**: This is a system API.
7802
7803**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7804
7805**Parameters**
7806
7807| Name       | Type     | Mandatory  | Description                                |
7808| ---------- | ------- | ---- | ---------------------------------- |
7809| displayLevel | number | Yes   | Display level to set.<br>The options are as follows:<br>**0**: unfavorite the portrait album.<br>**1**: set the portrait album as the first to display.<br>**2**: do not display the portrait album as the first one.<br>**3**: favorite the portrait album.|
7810
7811**Error codes**
7812
7813For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7814
7815| ID| Error Message|
7816| -------- | ---------------------------------------- |
7817| 202        |  Called by non-system application.         |
7818| 401       |  if parameter is invalid.         |
7819| 14000011       | System inner fail.         |
7820
7821**Example**
7822
7823``` ts
7824import dataSharePredicates from '@ohos.data.dataSharePredicates';
7825
7826async function example() {
7827  try {
7828    console.info('setDisplayLevel Example')
7829    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7830    predicates.equalTo('user_display_level', 2);
7831    let fetchOptions: photoAccessHelper.FetchOptions = {
7832      fetchColumns: [],
7833      predicates: predicates
7834    };
7835    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
7836    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7837    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7838    changeRequest.setDisplayLevel(1);
7839    await phAccessHelper.applyChanges(changeRequest);
7840  } catch (err) {
7841    console.error('setDisplayLevel failed with error: ' + err);
7842  }
7843}
7844```
7845
7846### setIsMe<sup>11+</sup>
7847
7848setIsMe(): void
7849
7850Sets the relationship between people in the portrait album to **Me**.
7851
7852**System API**: This is a system API.
7853
7854**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7855
7856**Error codes**
7857
7858For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7859
7860| ID| Error Message|
7861| -------- | ---------------------------------------- |
7862| 202        |  Called by non-system application.         |
7863| 401       |  if parameter is invalid.         |
7864| 14000011       | System inner fail.         |
7865
7866**Example**
7867
7868``` ts
7869import dataSharePredicates from '@ohos.data.dataSharePredicates';
7870
7871async function example() {
7872  try {
7873    console.info('setIsMe Example')
7874    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7875    predicates.equalTo('user_display_level', 2);
7876    let fetchOptions: photoAccessHelper.FetchOptions = {
7877      fetchColumns: [],
7878      predicates: predicates
7879    };
7880    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
7881    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7882    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7883    changeRequest.setIsMe();
7884    await phAccessHelper.applyChanges(changeRequest);
7885  } catch (err) {
7886    console.error('setIsMe failed with error: ' + err);
7887  }
7888}
7889```
7890
7891### dismissAssets<sup>11+</sup>
7892
7893dismissAssets(assets: Array&lt;PhotoAsset&gt;): void
7894
7895Removes assets from the portrait album.
7896
7897**System API**: This is a system API.
7898
7899**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7900
7901**Parameters**
7902
7903| Name       | Type     | Mandatory  | Description                                |
7904| ---------- | ------- | ---- | ---------------------------------- |
7905| assets | Array&lt;PhotoAsset&gt; | Yes   | Assets to remove.|
7906
7907**Error codes**
7908
7909For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7910
7911| ID| Error Message|
7912| -------- | ---------------------------------------- |
7913| 202        |  Called by non-system application.         |
7914| 401       |  if parameter is invalid.         |
7915| 14000011       | System inner fail.         |
7916| 14000016       | Operation Not support.         |
7917
7918**Example**
7919
7920``` ts
7921import dataSharePredicates from '@ohos.data.dataSharePredicates';
7922
7923async function example() {
7924  try {
7925    console.info('dismissAssets Example')
7926    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7927    predicates.equalTo('user_display_level', 2);
7928    let fetchOptions: photoAccessHelper.FetchOptions = {
7929      fetchColumns: [],
7930      predicates: predicates
7931    };
7932    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
7933    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7934
7935    let predicatesAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7936    let assetFetchOptions: photoAccessHelper.FetchOptions = {
7937      fetchColumns: [],
7938      predicates: predicatesAsset
7939    };
7940    let assetFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(assetFetchOptions);
7941    let asset: photoAccessHelper.PhotoAsset = await assetFetchResult.getFirstObject();
7942
7943    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
7944    changeRequest.dismissAssets([asset]);
7945    await phAccessHelper.applyChanges(changeRequest);
7946  } catch (err) {
7947    console.error('dismissAssets failed with error: ' + err);
7948  }
7949}
7950```
7951
7952### mergeAlbum<sup>11+</sup>
7953
7954mergeAlbum(target: Album): void
7955
7956Merges two portrait albums.
7957
7958**System API**: This is a system API.
7959
7960**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
7961
7962**Parameters**
7963
7964| Name       | Type     | Mandatory  | Description                                |
7965| ---------- | ------- | ---- | ---------------------------------- |
7966| target | [Album](#album) | Yes   | Album generated after the merge. The album must be renamed.|
7967
7968**Error codes**
7969
7970For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
7971
7972| ID| Error Message|
7973| -------- | ---------------------------------------- |
7974| 202        |  Called by non-system application.         |
7975| 401       |  if parameter is invalid.         |
7976| 14000011       | System inner fail.         |
7977| 14000016       | Operation Not support.         |
7978
7979**Example**
7980
7981``` ts
7982import dataSharePredicates from '@ohos.data.dataSharePredicates';
7983
7984async function example() {
7985  try {
7986    console.info('mergeAlbum Example')
7987    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
7988    predicates.equalTo('user_display_level', 2);
7989    let fetchOptions: photoAccessHelper.FetchOptions = {
7990      fetchColumns: [],
7991      predicates: predicates
7992    };
7993    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
7994    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
7995    if (fetchResult.isAfterLast()) {
7996      console.error('lack of album to merge');
7997      return;
7998    }
7999    let target: photoAccessHelper.Album = await fetchResult.getNextObject();
8000
8001    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
8002    changeRequest.mergeAlbum(target);
8003    changeRequest.setAlbumName("testName");
8004    await phAccessHelper.applyChanges(changeRequest);
8005  } catch (err) {
8006    console.error('mergeAlbum failed with error: ' + err);
8007  }
8008}
8009```
8010
8011### placeBefore<sup>11+</sup>
8012
8013placeBefore(album: Album): void;
8014
8015Places this album before an album.
8016
8017**System API**: This is a system API.
8018
8019**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8020
8021**Parameters**
8022
8023| Name       | Type     | Mandatory  | Description                                |
8024| ---------- | ------- | ---- | ---------------------------------- |
8025| album | [Album](#album) | Yes  |  Target album. To place this album to the end, set **album** to null.|
8026
8027**Error codes**
8028
8029For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
8030
8031| ID| Error Message|
8032| -------- | ---------------------------------------- |
8033| 202      |  Called by non-system application.         |
8034| 401       |  if parameter is invalid.         |
8035| 14000011       | System inner fail.         |
8036
8037**Example**
8038
8039```ts
8040async function example() {
8041  console.info('placeBeforeDemo');
8042  try {
8043    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
8044    let firstAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
8045    if (albumFetchResult.isAfterLast()) {
8046      console.error('lack of album to place before');
8047      return;
8048    }
8049    let secondAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject();
8050    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(secondAlbum);
8051    albumChangeRequest.placeBefore(firstAlbum);
8052    await phAccessHelper.applyChanges(albumChangeRequest);
8053    console.info('placeBefore successfully');
8054  } catch (err) {
8055    console.error('placeBeforeDemo failed with error: ' + err);
8056  }
8057}
8058```
8059
8060## MediaAssetManager<sup>11+</sup>
8061### requestImage<sup>11+</sup>
8062
8063static requestImage(context: Context, asset: PhotoAsset, requestOption: RequestOptions, dataHandler: MediaAssetDataHandler&lt;image.ImageSource&gt;): Promise&lt;string&gt;
8064
8065Requests an image.
8066
8067**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8068
8069**Required permissions**: ohos.permission.READ_IMAGEVIDEO
8070
8071**Parameters**
8072
8073| Name           | Type                                                                                                       | Mandatory| Description                     |
8074|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
8075| context        | [Context](js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
8076| assets         | [PhotoAsset](#photoasset)                                                                                | Yes  | Image to request.|
8077| requestOptions | [RequestOptions](#requestoptions11)                                                                        | Yes  | Options for requesting the image.
8078| dataHandler    | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;[image.ImageSource](js-apis-image.md#imagesource)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.
8079
8080**Error codes**
8081
8082For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
8083
8084| ID| Error Message|
8085| -------- | ---------------------------------------- |
8086| 201      |  Permission denied         |
8087| 401      |  if parameter is invalid.         |
8088| 14000011       | System inner fail.         |
8089
8090**Example**
8091
8092```ts
8093import dataSharePredicates from '@ohos.data.dataSharePredicates';
8094class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
8095    onDataPrepared(data: image.ImageSource) {
8096        console.info('on image data prepared');
8097    }
8098}
8099
8100async function example() {
8101  console.info('requestImage');
8102  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
8103  let fetchOptions: photoAccessHelper.FetchOptions = {
8104    fetchColumns: [],
8105    predicates: predicates
8106  };
8107  let requestOptions: photoAccessHelper.RequestOptions = {
8108    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
8109    sourceMode: photoAccessHelper.SourceMode.ORIGINAL_MODE
8110  }
8111  const handler = new MediaHandler();
8112
8113  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
8114      console.info('fetchResult success');
8115      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
8116      await photoAccessHelper.MediaAssetManager.requestImage(context, photoAsset, requestOptions, handler);
8117      console.info('requestImage successfully');
8118  });
8119}
8120```
8121
8122### requestImageData<sup>11+</sup>
8123
8124static requestImageData(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler, MediaAssetDataHandler&lt;ArrayBuffer&gt;): Promise&lt;string&gt;
8125
8126Requests an image.
8127
8128**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8129
8130**Required permissions**: ohos.permission.READ_IMAGEVIDEO
8131
8132**Parameters**
8133
8134| Name  | Type                                                                  | Mandatory| Description                     |
8135| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
8136| context | [Context](js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
8137| assets | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
8138| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the image.
8139| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;ArrayBuffer&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.
8140
8141**Error codes**
8142
8143For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md) and [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
8144
8145| ID| Error Message|
8146| -------- | ---------------------------------------- |
8147| 201      |  Permission denied         |
8148| 401      |  if parameter is invalid.         |
8149| 14000011       | System inner fail.         |
8150
8151**Example**
8152
8153```ts
8154import dataSharePredicates from '@ohos.data.dataSharePredicates';
8155class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
8156    onDataPrepared(data: ArrayBuffer) {
8157        console.info('on image data prepared');
8158    }
8159}
8160
8161async function example() {
8162  console.info('requestImageData');
8163  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
8164  let fetchOptions: photoAccessHelper.FetchOptions = {
8165    fetchColumns: [],
8166    predicates: predicates
8167  };
8168  let requestOptions: photoAccessHelper.RequestOptions = {
8169    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
8170    sourceMode: photoAccessHelper.SourceMode.ORIGINAL_MODE
8171  }
8172  const handler = new MediaDataHandler();
8173
8174  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
8175      console.info('fetchResult success');
8176      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
8177      await photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler);
8178      console.info('requestImageData successfully');
8179  });
8180}
8181```
8182
8183## MediaAssetDataHandler<sup>11+</sup>
8184
8185Media asset handler, which can be used to customize the media asset processing logic in **onDataPrepared**.
8186
8187**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8188
8189### onDataPrepared<sup>11+</sup>
8190
8191onDataPrepared(data: T): void
8192
8193Called when the requested image is ready.
8194**T** supports two data types: ArrayBuffer and [ImageSource](js-apis-image.md#imagesource).
8195
8196**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8197
8198**Parameters**
8199
8200| Name | Type| Mandatory| Description                                                                           |
8201|------|---| ---- |-------------------------------------------------------------------------------|
8202| data | T | Yes  | Data type, which can be an ArrayBuffer or [ImageSource](js-apis-image.md#imagesource).|
8203
8204**Example**
8205```ts
8206class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
8207  onDataPrepared(data: image.ImageSource) {
8208    // Customize the processing logic for ImageSource.
8209    console.info('on image data prepared');
8210  }
8211}
8212
8213class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
8214  onDataPrepared(data: ArrayBuffer) {
8215    // Customize the processing logic for ImageSource.
8216    console.info('on image data prepared');
8217  }
8218}
8219```
8220
8221## MemberType
8222
8223Enumerates the member types.
8224
8225**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8226
8227| Name |  Type|  Readable |  Writable |  Description |
8228| ----- |  ---- |  ---- |  ---- |  ---- |
8229| number |  number | Yes| Yes| The member is a number.|
8230| string |  string | Yes| Yes| The member is a string.|
8231| boolean |  boolean | Yes| Yes| The member is a Boolean value.|
8232
8233## PhotoType
8234
8235Enumerates media file types.
8236
8237**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8238
8239| Name |  Value|  Description|
8240| ----- |  ---- |  ---- |
8241| IMAGE |  1 |  Image.|
8242| VIDEO |  2 |  Video.|
8243
8244## PhotoSubtype
8245
8246Enumerates the [PhotoAsset](#photoasset) types.
8247
8248**System API**: This is a system API.
8249
8250**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8251
8252| Name |  Value|  Description|
8253| ----- |  ---- |  ---- |
8254| DEFAULT |  0 |  Default (photo) type.|
8255| SCREENSHOT |  1 |  Screenshot and screen recording file.|
8256
8257## PositionType
8258
8259Enumerates the file locations.
8260
8261**System API**: This is a system API.
8262
8263**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8264
8265| Name |  Value|  Description|
8266| ----- |  ---- |  ---- |
8267| LOCAL |  1 << 0 |  Stored only on a local device.|
8268| CLOUD |  1 << 1 |  Stored only on the cloud.|
8269
8270## AlbumType
8271
8272Enumerates the album types.
8273
8274**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8275
8276| Name                 | Value   | Description                       |
8277| ------------------- | ---- | ------------------------- |
8278| USER                | 0    | User album.                    |
8279| SYSTEM              | 1024 | System album.                  |
8280| SMART<sup>11+</sup> | 4096 | Smart analysis album. **System API**: This is a system API.|
8281
8282## AlbumSubtype
8283
8284Enumerate the album subtypes.
8285
8286**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8287
8288| Name                               | Value         | Description                             |
8289| --------------------------------- | ---------- | ------------------------------- |
8290| USER\_GENERIC                     | 1          | User album.                          |
8291| FAVORITE                          | 1025       | Favorites.                           |
8292| VIDEO                             | 1026       | Video album.                          |
8293| HIDDEN                            | 1027       | Hidden album. **System API**: This is a system API.        |
8294| TRASH                             | 1028       | Trash. **System API**: This is a system API.         |
8295| SCREENSHOT                        | 1029       | Album for screenshots and screen recording files. **System API**: This is a system API.     |
8296| CAMERA                            | 1030       | Album for photos and videos taken by the camera. **System API**: This is a system API.|
8297| IMAGE<sup>11+</sup>               | 1031       | Album for images. **System API**: This is a system API.      |
8298| SOURCE\_GENERIC<sup>11+</sup>     | 2049       | Source album. **System API**: This is a system API.        |
8299| CLASSIFY<sup>11+</sup>            | 4097       | Classified album. **System API**: This is a system API.        |
8300| GEOGRAPHY\_LOCATION<sup>11+</sup> | 4099       | Geographic location album. **System API**: This is a system API.        |
8301| GEOGRAPHY\_CITY<sup>11+</sup>     | 4100       | City album. **System API**: This is a system API.        |
8302| SHOOTING\_MODE<sup>11+</sup>      | 4101       | Shooting mode album. **System API**: This is a system API.      |
8303| PORTRAIT<sup>11+</sup>            | 4102       | Portrait album. **System API**: This is a system API.        |
8304| ANY                               | 2147483647 | Any album.                          |
8305
8306## RequestPhotoType<sup>11+</sup>
8307
8308Enumerates the types of the operation for obtaining image or video thumbnails.
8309
8310**System API**: This is a system API.
8311
8312**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8313
8314| Name |  Value|  Description|
8315| ----- |  ---- |  ---- |
8316| REQUEST_ALL_THUMBNAILS  |  0 |  Obtain both the quick thumbnail and the quality thumbnail.|
8317| REQUEST_FAST_THUMBNAIL |  1 |  Obtain only the quick thumbnail.|
8318| REQUEST_QUALITY_THUMBNAIL |  2 |  Obtain only the quality thumbnail.|
8319
8320## PhotoKeys
8321
8322Defines the key information about an image or video file.
8323
8324**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8325
8326| Name         | Value             | Description                                                      |
8327| ------------- | ------------------- | ---------------------------------------------------------- |
8328| URI           | 'uri'                 | URI of the file.                                                  |
8329| PHOTO_TYPE    | 'media_type'           | Type of the file.                                             |
8330| DISPLAY_NAME  | 'display_name'        | File name displayed.                                                  |
8331| SIZE          | 'size'                | File size.                                                  |
8332| DATE_ADDED    | 'date_added'          | Date when the file was added. The value is the number of seconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970).            |
8333| DATE_MODIFIED | 'date_modified'       | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
8334| DURATION      | 'duration'            | Duration, in ms.                                   |
8335| WIDTH         | 'width'               | Image width, in pixels.                                   |
8336| HEIGHT        | 'height'              | Image height, in pixels.                                     |
8337| DATE_TAKEN    | 'date_taken'          | Date when the file (photo) was taken. The value is the number of seconds elapsed since the Epoch time.               |
8338| ORIENTATION   | 'orientation'         | Orientation of the image file.                                            |
8339| FAVORITE      | 'is_favorite'            | Whether the file is added to favorites.                                                   |
8340| TITLE         | 'title'               | Title in the file.                                                  |
8341| POSITION  | 'position'            | File location type. **System API**: This is a system API.                              |
8342| DATE_TRASHED  | 'date_trashed'  | Date when the file was deleted. The value is the number of seconds elapsed since the Epoch time. **System API**: This is a system API.                |
8343| HIDDEN  | 'hidden'            | Whether the file is hidden. **System API**: This is a system API.                              |
8344| CAMERA_SHOT_KEY  | 'camera_shot_key'  | Key for the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.) **System API**: This is a system API.           |
8345| USER_COMMENT<sup>10+</sup>  | 'user_comment'            | User comment information. **System API**: This is a system API.          |
8346| DATE_YEAR<sup>11+</sup>  | 'date_year'            | Year when the file was created. **System API**: This is a system API.          |
8347| DATE_MONTH<sup>11+</sup>  | 'date_month'            | Month when the file was created. **System API**: This is a system API.          |
8348| DATE_DAY<sup>11+</sup>  | 'date_day'            | Date when the file was created. **System API**: This is a system API.          |
8349| PENDING<sup>11+</sup>  | 'pending'            | Pending state. **System API**: This is a system API.          |
8350
8351## AlbumKeys
8352
8353Enumerates the key album attributes.
8354
8355**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8356
8357| Name         | Value             | Description                                                      |
8358| ------------- | ------------------- | ---------------------------------------------------------- |
8359| URI           | 'uri'                 | URI of the album.                                                  |
8360| ALBUM_NAME    | 'album_name'          | Name of the album.                                                  |
8361
8362## HiddenPhotosDisplayMode<sup>11+</sup>
8363
8364Enumerates the display modes of hidden files in the system.
8365
8366**System API**: This is a system API.
8367
8368**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8369
8370| Name         | Value             | Description                                                      |
8371| ------------- | ------------------- | ---------------------------------------------------------- |
8372| ASSETS_MODE   | 0       | Display all hidden files in the system.   |
8373| ALBUMS_MODE    | 1    | Display hidden files by album (display all albums that contain hidden files in the system, excluding the preset hidden album and the albums in the trash). |
8374
8375## PhotoCreateOptions
8376
8377Defines the options for creating an image or video asset.
8378
8379**System API**: This is a system API.
8380
8381**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8382
8383| Name                  | Type               | Mandatory| Description                                             |
8384| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
8385| subtype           | [PhotoSubtype](#photosubtype) | No | Subtype of the image or video. |
8386| cameraShotKey           | string | No | Key for the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.)  |
8387
8388## CreateOptions
8389
8390Options for creating an image or video asset.
8391
8392The title must comply with the following specifications:
8393- The title cannot contain the filename extension.
8394- The title cannot exceed 255 characters.
8395- The title cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
8396
8397**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8398
8399| Name                  | Type               | Mandatory| Description                                             |
8400| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
8401| title           | string | No | Title of the image or video. |
8402
8403## RequestPhotoOptions<sup>11+</sup>
8404
8405Defines the options for obtaining the thumbnail of an image or video.
8406
8407**System API**: This is a system API.
8408
8409**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8410
8411| Name                  | Type               | Mandatory| Description                                             |
8412| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
8413| size           | [image.Size](js-apis-image.md#size) | No | Size of the thumbnail to obtain. |
8414| requestPhotoType    | [RequestPhotoType](#requestphototype11) | No | Operation to perform. |
8415
8416## FetchOptions
8417
8418Defines the options for fetching media files.
8419
8420**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8421
8422| Name                  | Type               | Readable| Writable| Description                                             |
8423| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
8424| fetchColumns           | Array&lt;string&gt; | Yes  | Yes  | Options for fetching files based on the attributes in columns. If this parameter is left empty, files are fetched by URI, name, and type (the specific field names vary with the file asset or album object) by default. In addition, an error will be reported if [get](#get) is called to obtain other attributes of this object. For example,<br>**fetchColumns: ['uri', 'title']**.|
8425| predicates           | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Yes  | Predicates that specify the fetch criteria.|
8426
8427## RequestOptions<sup>11+</sup>
8428
8429Represents request options.
8430
8431**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8432
8433| Name                  | Type                             | Readable| Writable| Description                                             |
8434| ---------------------- |---------------------------------| ---- |---- | ------------------------------------------------ |
8435| deliveryMode           | [DeliveryMode](#deliverymode11) | Yes  | Yes  | Delivery mode of the requested asset, which can be fast mode, high-quality mode, or balance mode.|
8436| sourceMode           | [SourceMode](#sourcemode11)     | Yes  | Yes  | Type of the asset file requested, which can be the original file or edited file. **System API**: This is a system API.|
8437
8438## PhotoProxy<sup>11+</sup>
8439
8440Photo proxy object, which is used by the camera application to write image data.
8441
8442**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8443
8444## MediaChangeRequest<sup>11+</sup>
8445
8446Media change request, which is the parent class of the asset change request and album change request.
8447
8448**NOTE**<br>**MediaChangeRequest** takes effect only after [applyChanges](#applychanges11) is called.
8449
8450**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8451
8452## FormInfo<sup>11+</sup>
8453
8454Defines the Gallery widget information.
8455
8456**System API**: This is a system API.
8457
8458**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8459
8460| Name                  | Type               | Mandatory| Description                                             |
8461| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
8462|formId       |string  |Yes| Widget ID, which is provided when a widget is created in Gallery.|
8463|uri          |string  |Yes| URI of the image bound to the widget. When a widget is created, **uri** can be empty or the URI of an image. When a widget is removed, **uri** is not verified and can be empty. |
8464
8465## ResourceType<sup>11+</sup>
8466
8467Enumerates the types of the resources to write.
8468
8469**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8470
8471| Name |  Value|  Description|
8472| ----- |  ---- |  ---- |
8473| IMAGE_RESOURCE |  1 |  Image resource.|
8474| VIDEO_RESOURCE |  2 |  Video resource.|
8475| PHOTO_PROXY |  3 |  Photo proxy. **System API**: This is a system API.|
8476
8477## ChangeData
8478
8479Defines the return value of the listener callback.
8480
8481**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8482
8483| Name   | Type                       | Readable| Writable| Description                                                        |
8484| ------- | --------------------------- | ---- | ---- | ------------------------------------------------------------ |
8485| type    | [NotifyType](#notifytype) | Yes  | No  | Notification type.                                      |
8486| uris    | Array&lt;string&gt;         | Yes  | No  | All URIs with the same [NotifyType](#notifytype), which can be **PhotoAsset** or **Album**.|
8487| extraUris | Array&lt;string&gt;         | Yes  | No  | URIs of the changed files in the album.                                   |
8488
8489## NotifyType
8490
8491Enumerates the notification event types.
8492
8493**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8494
8495| Name                     | Value  | Description                            |
8496| ------------------------- | ---- | -------------------------------- |
8497| NOTIFY_ADD                | 0    | A file asset or album is added.    |
8498| NOTIFY_UPDATE             | 1    | A file asset or album is updated.    |
8499| NOTIFY_REMOVE             | 2    | A file asset or album is removed.    |
8500| NOTIFY_ALBUM_ADD_ASSET    | 3    | A file asset is added to the album.|
8501| NOTIFY_ALBUM_REMOVE_ASSET | 4    | A file asset is removed from the album.|
8502
8503## DefaultChangeUri
8504
8505Enumerates the **DefaultChangeUri** subtypes.
8506
8507**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8508
8509| Name             | Value                     | Description                                                        |
8510| ----------------- | ----------------------- | ------------------------------------------------------------ |
8511| DEFAULT_PHOTO_URI | 'file://media/Photo'      | Default **PhotoAsset** URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all photo assets.|
8512| DEFAULT_ALBUM_URI | 'file://media/PhotoAlbum' | Default album URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all albums.|
8513| DEFAULT_HIDDEN_ALBUM_URI<sup>11+</sup>  | 'file://media/HiddenAlbum' | URI of an album in the hidden albums that are displayed by album, that is, the URI of an album with hidden files. Such albums do not include the preset hidden album and the albums in the trash. This URI is used to subscribe to the change notifications of the hidden albums displayed by album. **System API**: This is a system API.|
8514
8515## PhotoViewMIMETypes
8516
8517Enumerates the media file types that can be selected.
8518
8519**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8520
8521| Name |  Value|  Description|
8522| ----- |  ---- | ---- |
8523| IMAGE_TYPE  |  'image/*' | Image.|
8524| VIDEO_TYPE |  'video/*' | Video.|
8525| IMAGE_VIDEO_TYPE |  '\*/*' | Image and video.|
8526
8527## RecommendationType<sup>11+</sup>
8528
8529Enumerates the types of recommended images.
8530
8531**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8532
8533| Name |  Value|  Description|
8534| ----- |  ---- | ---- |
8535| QR_OR_BAR_CODE  |  1 | QR code or barcode.|
8536| QR_CODE |  2 | QR code.|
8537| BAR_CODE |  3 | Barcode.|
8538| ID_CARD |  4 | ID card.|
8539| PROFILE_PICTURE |  5 | Profile.|
8540
8541## RecommendationOptions<sup>11+</sup>
8542
8543Defines the image recommendation options. The image recommendation feature depends on the image data analysis capability, which varies with devices.
8544
8545**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8546
8547| Name                   | Type               | Mandatory| Description                         |
8548| ----------------------- | ------------------- | ---- | -------------------------------- |
8549| recommendationType | [RecommendationType](#recommendationtype11)   | No  | Type of the recommended image. If this parameter is not specified, images are not recommended by default.|
8550
8551## PhotoSelectOptions
8552
8553Defines the options for selecting images or videos.
8554
8555**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8556
8557| Name                   | Type               | Mandatory| Description                         |
8558| ----------------------- | ------------------- | ---- | -------------------------------- |
8559| MIMEType              | [PhotoViewMIMETypes](#photoviewmimetypes)   | No  | Available media file types. **IMAGE_VIDEO_TYPE** is used by default.|
8560| maxSelectNumber       | number | No  | Maximum number of media files that can be selected. The default value is **50**, and the maximum value is **500**.     |
8561| isPhotoTakingSupported<sup>11+</sup> | boolean  | No  | Whether photo taking is supported.|
8562| isEditSupported<sup>11+</sup>       | boolean | No  | Whether the image is editable.     |
8563| isSearchSupported<sup>11+</sup> | boolean  | No  | Whether the image is searchable.|
8564| recommendationOptions<sup>11+</sup>       | [RecommendationOptions](#recommendationoptions11)   | No  | Recommended image.     |
8565
8566## PhotoSelectResult
8567
8568Defines information about the images or videos selected.
8569
8570**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8571
8572| Name                   | Type               | Readable| Writable| Description                          |
8573| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
8574| photoUris        | Array&lt;string&gt;    | Yes  | Yes  | URIs of the images or videos selected. The URI array can be used only by calling [photoAccessHelper.getAssets](#getassets) with temporary authorization. For details about how to use the media file URI, see [Using a Media File URI] (../../file-management/user-file-uri-intro.md#using-a-media-file-uri).|
8575| isOriginalPhoto        | boolean    | Yes  | Yes  | Whether the selected media asset is the original image.|
8576
8577
8578## DeliveryMode<sup>11+</sup>
8579
8580Enumerates the image delivery modes.
8581
8582**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8583
8584| Name |  Value|  Description|
8585| ----- |  ---- |  ---- |
8586| FAST_MODE |  1 |  Fast mode.|
8587| HIGH_QUALITY_MODE |  2 |  High-quality mode.|
8588| BALANCE_MODE |  3 |  Balance mode.|
8589
8590## SourceMode<sup>11+</sup>
8591
8592Enumerates the types of the file to read.
8593
8594**System API**: This is a system API.
8595
8596**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8597
8598| Name |  Value|  Description|
8599| ----- |  ---- |  ---- |
8600| ORIGINAL_MODE |  0 |  Original file.|
8601| EDITED_MODE |  1 |  Edited file.|
8602
8603## AnalysisType<sup>11+</sup>
8604
8605Enumerates the smart analysis types.
8606
8607**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
8608
8609| Name                           | Value | Description      |
8610| :---------------------------- | :- | :------- |
8611| ANALYSIS\_AESTHETICS\_SCORE   | 0  | Aesthetics score. <br>**System API**: This is a system API.   |
8612| ANALYSIS\_LABEL               | 1  | Label. <br>**System API**: This is a system API.   |
8613| ANALYSIS\_OCR                 | 2  | Optical character recognition (OCR) analysis. <br>**System API**: This is a system API.   |
8614| ANALYSIS\_FACE                | 3  | Facial detection analysis. <br>**System API**: This is a system API.   |
8615| ANALYSIS\_OBJECT              | 4  | Object detection analysis. <br>**System API**: This is a system API.   |
8616| ANALYSIS\_RECOMMENDATION      | 5  | Recommendation analysis. <br>**System API**: This is a system API.   |
8617| ANALYSIS\_SEGMENTATION        | 6  | Segmentation analysis. <br>**System API**: This is a system API.   |
8618| ANALYSIS\_COMPOSITION         | 7  | Aesthetic composition analysis. <br>**System API**: This is a system API.  |
8619| ANALYSIS\_SALIENCY            | 8  | Salience analysis. <br>**System API**: This is a system API.  |
8620| ANALYSIS\_DETAIL\_ADDRESS     | 9  | Detailed address analysis. <br>**System API**: This is a system API.   |
8621