• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.sendablePhotoAccessHelper (Album Management Based on a Sendable Object)
2
3The sendablePhotoAccessHelper module provides APIs for album management, including creating an album and accessing and modifying media data in an album, based on a [Sendable](../../arkts-utils/arkts-sendable.md) object.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { sendablePhotoAccessHelper } from '@kit.MediaLibraryKit';
13```
14
15## sendablePhotoAccessHelper.getPhotoAccessHelper
16
17getPhotoAccessHelper(context: Context): PhotoAccessHelper
18
19Obtains a **PhotoAccessHelper** instance, which can be used for accessing and modifying media files in an album.
20
21**Model restriction**: This API can be used only in the stage model.
22
23**Atomic service API**: This API can be used in atomic services since API version 12.
24
25**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
26
27**Parameters**
28
29| Name | Type                                                        | Mandatory| Description                      |
30| ------- | ------------------------------------------------------------ | ---- | -------------------------- |
31| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
32
33**Return value**
34
35| Type                                   | Description                |
36| --------------------------------------- | :------------------- |
37| [PhotoAccessHelper](#photoaccesshelper) | **PhotoAccessHelper** instance obtained.|
38
39**Error codes**
40
41For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
42
43| ID| Error Message                                                    |
44| -------- | ------------------------------------------------------------ |
45| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
46
47**Example**
48
49```ts
50// 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.
51let context = getContext(this);
52let phAccessHelper = sendablePhotoAccessHelper.getPhotoAccessHelper(context);
53```
54
55## PhotoAccessHelper
56
57### getAssets
58
59getAssets(options: photoAccessHelper.FetchOptions): Promise<FetchResult<PhotoAsset>>
60
61Obtains media assets. This API uses a promise to return the result.
62
63**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
64
65**Required permissions**: ohos.permission.READ_IMAGEVIDEO
66
67If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
68
69**Parameters**
70
71| Name | Type                                                     | Mandatory| Description                |
72| ------- | --------------------------------------------------------- | ---- | -------------------- |
73| options | [photoAccessHelper.FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes  | Options for fetching the media assets.|
74
75**Return value**
76
77| Type                                                        | Description                                   |
78| ------------------------------------------------------------ | --------------------------------------- |
79| Promise<[FetchResult](#fetchresult)<[PhotoAsset](#photoasset)>> | Promise used to return the media assets obtained.|
80
81**Error codes**
82
83For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
84
85| ID| Error Message                                                    |
86| -------- | ------------------------------------------------------------ |
87| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
88| 201      | Permission denied.                                           |
89| 14000011 | Internal system error.                                        |
90
91**Example**
92
93
94
95```ts
96import { dataSharePredicates } from '@kit.ArkData';
97import { photoAccessHelper } from '@kit.MediaLibraryKit';
98
99async function example() {
100  console.info('getAssets');
101  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
102  let fetchOptions: photoAccessHelper.FetchOptions = {
103    fetchColumns: [],
104    predicates: predicates
105  };
106  try {
107    let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
108    if (fetchResult !== undefined) {
109      console.info('fetchResult success');
110      let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
111      if (photoAsset !== undefined) {
112        console.info('photoAsset.displayName :' + photoAsset.displayName);
113      }
114    }
115  } catch (err) {
116    console.error(`getAssets failed, error: ${err.code}, ${err.message}`);
117  }
118}
119```
120
121### getBurstAssets
122
123getBurstAssets(burstKey: string, options: photoAccessHelper.FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
124
125Obtains burst assets. This API uses a promise to return the result.
126
127**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
128
129**Required permissions**: ohos.permission.READ_IMAGEVIDEO
130
131**Parameters**
132
133| Name  | Type                                                     | Mandatory| Description                                                        |
134| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
135| burstKey | string                                                    | Yes  | Universally Unique Identifier (UUID) of a group of burst photos, that is, **BURST_KEY** of [PhotoKeys](js-apis-photoAccessHelper.md#photokeys). The value is a string of 36 characters.|
136| options  | [photoAccessHelper.FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes  | Options for fetching the burst photos.                                          |
137
138**Return value**
139
140| Type                                                        | Description                                 |
141| ------------------------------------------------------------ | ------------------------------------- |
142| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the result.|
143
144**Error codes**
145
146For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
147
148| ID| Error Message                                                    |
149| -------- | ------------------------------------------------------------ |
150| 201      | Permission denied.                                           |
151| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
152| 14000011 | Internal system error.                                       |
153
154**Example**
155
156```ts
157import { photoAccessHelper } from '@kit.MediaLibraryKit';
158import { dataSharePredicates } from '@kit.ArkData';
159
160async function example() {
161  console.info('getBurstAssets');
162  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
163  let fetchOption: photoAccessHelper.FetchOptions = {
164    fetchColumns: [],
165    predicates: predicates
166  };
167  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
168  let photoAssetList: Array<sendablePhotoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
169  let photoAsset: sendablePhotoAccessHelper.PhotoAsset;
170  // burstKey is a 36-bit UUID, which can be obtained from photoAccessHelper.PhotoKeys.
171  for(photoAsset of photoAssetList){
172    let burstKey: string = photoAccessHelper.PhotoKeys.BURST_KEY.toString();
173    let photoAccessBurstKey: photoAccessHelper.MemberType = photoAsset.get(burstKey).toString();
174    try {
175      let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await
176      phAccessHelper.getBurstAssets(photoAccessBurstKey, fetchOption);
177      if (fetchResult !== undefined) {
178        console.info('fetchResult success');
179        let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
180        if (photoAsset !== undefined) {
181          console.info('photoAsset.displayName :' + photoAsset.displayName);
182        }
183      }
184    } catch (err) {
185      console.error(`getBurstAssets failed, error: ${err.code}, ${err.message}`);
186    }
187  }
188}
189```
190
191### createAsset
192
193createAsset(photoType: PhotoType, extension: string, options?: photoAccessHelper.CreateOptions): Promise&lt;string&gt;
194
195Creates a media asset with the specified file type, file name extension, and options. This API uses a promise to return the result.
196
197If the caller does not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component. For details, see [Creating a Media Asset Using a Security Component](../../media/medialibrary/photoAccessHelper-savebutton.md).
198
199**Atomic service API**: This API can be used in atomic services since API version 12.
200
201**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
202
203**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
204
205**Parameters**
206
207| Name   | Type                                                       | Mandatory| Description                                |
208| --------- | ----------------------------------------------------------- | ---- | ------------------------------------ |
209| photoType | [PhotoType](#phototype)                                     | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.|
210| extension | string                                                      | Yes  | File name extension, for example, **'jpg'**. The value contains 1 to 255 characters.       |
211| options   | [photoAccessHelper.CreateOptions](js-apis-photoAccessHelper.md#createoptions) | No  | Options for creating the media asset, for example, **{title: 'testPhoto'}**.|
212
213**Return value**
214
215| Type                 | Description                                    |
216| --------------------- | ---------------------------------------- |
217| Promise&lt;string&gt; | Promise used to return the URI of the created media asset.|
218
219**Error codes**
220
221For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
222
223| ID| Error Message                                                    |
224| -------- | ------------------------------------------------------------ |
225| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
226| 201      | Permission denied.                                           |
227| 14000011 | Internal system error.                                        |
228
229**Example**
230
231```ts
232import { photoAccessHelper } from '@kit.MediaLibraryKit';
233
234async function example() {
235  console.info('createAssetDemo');
236  try {
237    let photoType: sendablePhotoAccessHelper.PhotoType = sendablePhotoAccessHelper.PhotoType.IMAGE;
238    let extension: string = 'jpg';
239    let options: photoAccessHelper.CreateOptions = {
240      title: 'testPhoto'
241    }
242    let uri: string = await phAccessHelper.createAsset(photoType, extension, options);
243    console.info('createAsset uri' + uri);
244    console.info('createAsset successfully');
245  } catch (err) {
246    console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
247  }
248}
249```
250
251### getAlbums
252
253getAlbums(type: AlbumType, subtype: AlbumSubtype, options?: photoAccessHelper.FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
254
255Obtains albums based on the specified options and album type. This API uses a promise to return the result.
256
257Before the operation, ensure that the albums to obtain exist.
258
259**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
260
261**Required permissions**: ohos.permission.READ_IMAGEVIDEO
262
263**Parameters**
264
265| Name | Type                                                     | Mandatory| Description                                  |
266| ------- | --------------------------------------------------------- | ---- | -------------------------------------- |
267| type    | [AlbumType](#albumtype)                                   | Yes  | Type of the albums to obtain.                            |
268| subtype | [AlbumSubtype](#albumsubtype)                             | Yes  | Subtype of the album.                          |
269| options | [photoAccessHelper.FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | No  | Options for fetching the albums. If this parameter is not specified, the albums are obtained based on the album type by default.|
270
271**Return value**
272
273| Type                                                        | Description                               |
274| ------------------------------------------------------------ | ----------------------------------- |
275| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.|
276
277**Error codes**
278
279For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
280
281| ID| Error Message                                                    |
282| -------- | ------------------------------------------------------------ |
283| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
284| 201      | Permission denied.                                           |
285| 14000011 | Internal system error.                                        |
286
287**Example**
288
289```ts
290import { dataSharePredicates } from '@kit.ArkData';
291import { BusinessError } from '@kit.BasicServicesKit';
292import { photoAccessHelper } from '@kit.MediaLibraryKit';
293
294async function example() {
295  // Obtain the album named newAlbumName.
296  console.info('getAlbumsDemo');
297  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
298  predicates.equalTo('album_name', 'newAlbumName');
299  let fetchOptions: photoAccessHelper.FetchOptions = {
300    fetchColumns: [],
301    predicates: predicates
302  };
303  phAccessHelper.getAlbums(sendablePhotoAccessHelper.AlbumType.USER, sendablePhotoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions).then( async (fetchResult) => {
304    if (fetchResult === undefined) {
305      console.error('getAlbumsPromise fetchResult is undefined');
306      return;
307    }
308    let album: sendablePhotoAccessHelper.Album = await fetchResult.getFirstObject();
309    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
310    fetchResult.close();
311  }).catch((err: BusinessError) => {
312    console.error(`getAlbumsPromise failed with err: ${err.code}, ${err.message}`);
313  });
314}
315```
316
317### getAlbums
318
319getAlbums(options: photoAccessHelper.FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
320
321Obtains albums. This API uses a promise to return the result.
322
323Before the operation, ensure that the albums to obtain exist.
324
325**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
326
327**Required permissions**: ohos.permission.READ_IMAGEVIDEO
328
329**Parameters**
330
331| Name | Type                                                     | Mandatory| Description    |
332| ------- | --------------------------------------------------------- | ---- | -------- |
333| options | [photoAccessHelper.FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes  | Options for fetching the albums.|
334
335**Return value**
336
337| Type                                                        | Description                               |
338| ------------------------------------------------------------ | ----------------------------------- |
339| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.|
340
341**Error codes**
342
343For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
344
345| ID| Error Message                                                    |
346| -------- | ------------------------------------------------------------ |
347| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
348| 201      | Permission denied.                                           |
349| 14000011 | Internal system error.                                        |
350
351**Example**
352
353```ts
354import { dataSharePredicates } from '@kit.ArkData';
355import { BusinessError } from '@kit.BasicServicesKit';
356import { photoAccessHelper } from '@kit.MediaLibraryKit';
357
358async function example() {
359  // Obtain the album named newAlbumName.
360  console.info('getAlbumsDemo');
361  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
362  predicates.equalTo('album_name', 'newAlbumName');
363  let fetchOptions: photoAccessHelper.FetchOptions = {
364    fetchColumns: [],
365    predicates: predicates
366  };
367  phAccessHelper.getAlbums(fetchOptions).then( async (fetchResult) => {
368    if (fetchResult === undefined) {
369      console.error('getAlbumsPromise fetchResult is undefined');
370      return;
371    }
372    let album: sendablePhotoAccessHelper.Album = await fetchResult.getFirstObject();
373    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
374    fetchResult.close();
375  }).catch((err: BusinessError) => {
376    console.error(`getAlbumsPromise failed with err: ${err.code}, ${err.message}`);
377  });
378}
379```
380
381### release
382
383release(): Promise&lt;void&gt;
384
385Releases this **PhotoAccessHelper** instance. This API uses a promise to return the result.
386Call this API when the APIs of the **PhotoAccessHelper** instance are no longer used.
387
388**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
389
390**Return value**
391
392| Type               | Description                   |
393| ------------------- | ----------------------- |
394| Promise&lt;void&gt; | Promise that returns no value.|
395
396**Error codes**
397
398For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
399
400| ID| Error Message                                                    |
401| -------- | ------------------------------------------------------------ |
402| 14000011 | Internal system error.                                        |
403
404**Example**
405
406```ts
407async function example() {
408  console.info('releaseDemo');
409  try {
410    console.info('use function...');
411  } catch (err) {
412    console.error(`function error ...`);
413  }finally{
414      try{
415          phAccessHelper?.release();
416          console.info(`release success`);
417      } catch(e){
418          console.error(`release error :${e}`);
419      }
420  }
421}
422```
423
424## PhotoAsset
425
426Provides APIs for encapsulating file asset attributes.
427
428### Properties
429
430**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
431
432| Name       | Type                   | Read-Only| Optional| Description                                                        |
433| ----------- | ----------------------- | ---- | ---- | ------------------------------------------------------------ |
434| uri<sup>12+</sup>         | 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).|
435| photoType<sup>12+</sup>   | [PhotoType](#phototype) | Yes  | No  | Type of the file.                                              |
436| displayName<sup>12+</sup> | string                  | Yes  | No  | File name, including the file name extension, to display. The value contains 1 to 255 characters.                                    |
437
438### convertToPhotoAsset
439
440convertToPhotoAsset():  photoAccessHelper.PhotoAsset
441
442Converts a Sendable **PhotoAsset** object to a non-Sendable **PhotoAsset** object.
443
444**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
445
446**Return value**
447
448| Type                        | Description                                                        |
449| ---------------------------- | ------------------------------------------------------------ |
450| photoAccessHelper.PhotoAsset | [PhotoAsset](js-apis-photoAccessHelper.md#photoasset) object of the non-Sendable type.|
451
452**Error codes**
453
454For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
455
456| ID| Error Message                                                    |
457| -------- | ------------------------------------------------------------ |
458| 201      | Permission denied.                                           |
459| 14000011 | Internal system error.                                        |
460
461**Example**
462
463```ts
464import { dataSharePredicates } from '@kit.ArkData';
465import { photoAccessHelper } from '@kit.MediaLibraryKit';
466
467async function example() {
468  console.info('convertToPhotoAssetDemo');
469  try {
470    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
471    let fetchOption: photoAccessHelper.FetchOptions = {
472      fetchColumns: ['title'],
473      predicates: predicates
474    };
475    let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
476    let sendablePhotoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
477    let photoAsset: photoAccessHelper.PhotoAsset = sendablePhotoAsset.convertToPhotoAsset();
478    console.log(`get no sendable uri success : ${photoAsset.uri}`);
479  } catch (err) {
480    console.error(`convertToPhotoAsset failed. error: ${err.code}, ${err.message}`);
481  }
482}
483```
484
485### get
486
487get(member: string): photoAccessHelper.MemberType
488
489Obtains a **PhotoAsset** member parameter.
490
491**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
492
493**Parameters**
494
495| Name| Type  | Mandatory| Description                                                        |
496| ------ | ------ | ---- | ------------------------------------------------------------ |
497| member | string | Yes  | Name of the member parameter to obtain. <br>Except **'uri'**, **'media_type'**, **'subtype'**, and **'display_name'**, you must pass in [PhotoKeys](js-apis-photoAccessHelper.md#photokeys) in **fetchColumns**. For example, to obtain the title, pass in **fetchColumns: ['title']**.|
498
499**Return value**
500
501| Type                                                 | Description                        |
502| ----------------------------------------------------- | ---------------------------- |
503| [photoAccessHelper.MemberType](js-apis-photoAccessHelper.md#membertype) | **PhotoAsset** member parameter obtained.|
504
505**Error codes**
506
507For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
508
509| ID| Error Message                                                    |
510| -------- | ------------------------------------------------------------ |
511| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
512
513**Example**
514
515```ts
516import { dataSharePredicates } from '@kit.ArkData';
517import { photoAccessHelper } from '@kit.MediaLibraryKit';
518
519async function example() {
520  console.info('photoAssetGetDemo');
521  try {
522    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
523    let fetchOption: photoAccessHelper.FetchOptions = {
524      fetchColumns: ['title'],
525      predicates: predicates
526    };
527    let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
528    let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
529    let title: photoAccessHelper.PhotoKeys = photoAccessHelper.PhotoKeys.TITLE;
530    let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title.toString());
531    console.info('photoAsset Get photoAssetTitle = ', photoAssetTitle);
532  } catch (err) {
533    console.error(`get failed. error: ${err.code}, ${err.message}`);
534  }
535}
536```
537
538### set
539
540set(member: string, value: string): void
541
542Sets a **PhotoAsset** member parameter.
543
544**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
545
546**Parameters**
547
548| Name| Type  | Mandatory| Description                                                        |
549| ------ | ------ | ---- | ------------------------------------------------------------ |
550| member | string | Yes  | Name of the parameter to set, for example, [PhotoKeys](js-apis-photoAccessHelper.md#photokeys).TITLE. The value contains 1 to 255 characters.|
551| value  | string | Yes  | Value to set. Only the value of [PhotoKeys](js-apis-photoAccessHelper.md#photokeys).TITLE can be changed. The title must meet the following requirements:<br>- It does not contain a file name extension.<br>- The file name, which is in the format of title+file name extension, does not exceed 255 characters.<br>- The title does not contain any of the following characters:\ / : * ? " ' ` < > \| { } [ ]  |
552
553**Error codes**
554
555For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
556
557| ID| Error Message                                                    |
558| -------- | ------------------------------------------------------------ |
559| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
560
561**Example**
562
563```ts
564import { dataSharePredicates } from '@kit.ArkData';
565import { photoAccessHelper } from '@kit.MediaLibraryKit';
566
567async function example() {
568  console.info('photoAssetSetDemo');
569  try {
570    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
571    let fetchOption: photoAccessHelper.FetchOptions = {
572      fetchColumns: ['title'],
573      predicates: predicates
574    };
575    let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
576    let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
577    let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
578    photoAsset.set(title, 'newTitle');
579  } catch (err) {
580    console.error(`set failed. error: ${err.code}, ${err.message}`);
581  }
582}
583```
584
585### commitModify
586
587commitModify(): Promise&lt;void&gt;
588
589Commits the modification on the file metadata to the database. This API uses a promise to return the result.
590
591**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
592
593**Atomic service API**: This API can be used in atomic services since API version 12.
594
595**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
596
597**Return value**
598
599| Type               | Description                   |
600| ------------------- | ----------------------- |
601| Promise&lt;void&gt; | Promise that returns no value.|
602
603**Error codes**
604
605For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
606
607| ID| Error Message                                                    |
608| -------- | ------------------------------------------------------------ |
609| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
610| 201      | Permission denied.                                           |
611| 14000011 | Internal system error.                                        |
612
613**Example**
614
615```ts
616import { dataSharePredicates } from '@kit.ArkData';
617import { photoAccessHelper } from '@kit.MediaLibraryKit';
618
619async function example() {
620  console.info('commitModifyDemo');
621  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
622  let fetchOption: photoAccessHelper.FetchOptions = {
623    fetchColumns: ['title'],
624    predicates: predicates
625  };
626  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
627  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
628  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
629  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
630  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
631  photoAsset.set(title, 'newTitle3');
632  try {
633    await photoAsset.commitModify();
634    let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
635    console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
636  } catch (err) {
637    console.error(`commitModify failed. error: ${err.code}, ${err.message}`);
638  }
639}
640```
641
642### getThumbnail
643
644getThumbnail(size?: image.Size): Promise&lt;image.PixelMap&gt;
645
646Obtains the file thumbnail of the given size. This API uses a promise to return the result.
647
648**Required permissions**: ohos.permission.READ_IMAGEVIDEO
649
650**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
651
652**Parameters**
653
654| Name| Type                                                 | Mandatory| Description        |
655| ------ | ----------------------------------------------------- | ---- | ------------ |
656| size   | [image.Size](../apis-image-kit/js-apis-image.md#size) | No  | Size of the thumbnail.|
657
658**Return value**
659
660| Type                                                        | Description                               |
661| ------------------------------------------------------------ | ----------------------------------- |
662| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Promise used to return the PixelMap of the thumbnail.|
663
664**Error codes**
665
666For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
667
668| ID| Error Message                                                    |
669| -------- | ------------------------------------------------------------ |
670| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
671| 201      | Permission denied.                                           |
672| 14000011 | Internal system error.                                        |
673
674**Example**
675
676```ts
677import { dataSharePredicates } from '@kit.ArkData';
678import { image } from '@kit.ImageKit';
679import { BusinessError } from '@kit.BasicServicesKit';
680import { photoAccessHelper } from '@kit.MediaLibraryKit';
681
682async function example() {
683  console.info('getThumbnailDemo');
684  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
685  let fetchOption: photoAccessHelper.FetchOptions = {
686    fetchColumns: [],
687    predicates: predicates
688  };
689  let size: image.Size = { width: 720, height: 720 };
690  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
691  let asset = await fetchResult.getFirstObject();
692  console.info('asset displayName = ', asset.displayName);
693  asset.getThumbnail(size).then((pixelMap) => {
694    console.info('getThumbnail successful ' + pixelMap);
695  }).catch((err: BusinessError) => {
696    console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
697  });
698}
699```
700
701## FetchResult
702
703Provides APIs to manage the file retrieval result.
704
705### getCount
706
707getCount(): number
708
709Obtains the total number of files in the result set.
710
711**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
712
713**Return value**
714
715| Type  | Description              |
716| ------ | ------------------ |
717| number | Total number of files obtained.|
718
719**Error codes**
720
721For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
722
723| ID| Error Message                                                    |
724| -------- | ------------------------------------------------------------ |
725| 14000011 | Internal system error.                                        |
726
727**Example**
728
729```ts
730import { dataSharePredicates } from '@kit.ArkData';
731import { photoAccessHelper } from '@kit.MediaLibraryKit';
732
733async function example() {
734  console.info('getCountDemo');
735  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
736  let fetchOption: photoAccessHelper.FetchOptions = {
737    fetchColumns: [],
738    predicates: predicates
739  };
740  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
741  let fetchCount = fetchResult.getCount();
742  console.info('fetchCount = ', fetchCount);
743}
744```
745
746### isAfterLast
747
748isAfterLast(): boolean
749
750Checks whether the cursor is in the last row of the result set.
751
752**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
753
754**Return value**
755
756| Type   | Description                                                       |
757| ------- | ----------------------------------------------------------- |
758| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.|
759
760**Error codes**
761
762For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
763
764| ID| Error Message                                                    |
765| -------- | ------------------------------------------------------------ |
766| 14000011 | Internal system error.                                        |
767
768**Example**
769
770```ts
771import { dataSharePredicates } from '@kit.ArkData';
772import { photoAccessHelper } from '@kit.MediaLibraryKit';
773
774async function example() {
775  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
776  let fetchOption: photoAccessHelper.FetchOptions = {
777    fetchColumns: [],
778    predicates: predicates
779  };
780  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
781  let fetchCount = fetchResult.getCount();
782  console.info('count:' + fetchCount);
783  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
784  if (fetchResult.isAfterLast()) {
785    console.info('photoAsset isAfterLast displayName = ', photoAsset.displayName);
786  } else {
787    console.info('photoAsset not isAfterLast.');
788  }
789}
790```
791
792### close
793
794close(): void
795
796Closes this **FetchFileResult** instance to invalidate it. After this instance is closed, the APIs in this instance cannot be invoked.
797
798**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
799
800**Error codes**
801
802For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
803
804| ID| Error Message                                                    |
805| -------- | ------------------------------------------------------------ |
806| 14000011 | Internal system error.                                        |
807
808**Example**
809
810```ts
811import { dataSharePredicates } from '@kit.ArkData';
812import { photoAccessHelper } from '@kit.MediaLibraryKit';
813
814async function example() {
815  console.info('fetchResultCloseDemo');
816  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
817  let fetchOption: photoAccessHelper.FetchOptions = {
818    fetchColumns: [],
819    predicates: predicates
820  };
821  try {
822    let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
823    fetchResult.close();
824    console.info('close succeed.');
825  } catch (err) {
826    console.error(`close fail. error: ${err.code}, ${err.message}`);
827  }
828}
829```
830
831### getFirstObject
832
833getFirstObject(): Promise&lt;T&gt;
834
835Obtains the first asset in the result set. This API uses a promise to return the result.
836
837**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
838
839**Return value**
840
841| Type            | Description                                 |
842| ---------------- | ------------------------------------- |
843| Promise&lt;T&gt; | Promise used to return the first object in the result set.|
844
845**Error codes**
846
847For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
848
849| ID| Error Message                                                    |
850| -------- | ------------------------------------------------------------ |
851| 14000011 | Internal system error.                                        |
852
853**Example**
854
855```ts
856import { dataSharePredicates } from '@kit.ArkData';
857import { photoAccessHelper } from '@kit.MediaLibraryKit';
858
859async function example() {
860  console.info('getFirstObjectDemo');
861  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
862  let fetchOption: photoAccessHelper.FetchOptions = {
863    fetchColumns: [],
864    predicates: predicates
865  };
866  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
867  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
868  console.info('photoAsset displayName: ', photoAsset.displayName);
869}
870```
871
872### getNextObject
873
874getNextObject(): Promise&lt;T&gt;
875
876Obtains the next asset in the result set. This API uses a promise to return the result.
877Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
878
879**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
880
881**Return value**
882
883| Type            | Description                                 |
884| ---------------- | ------------------------------------- |
885| Promise&lt;T&gt; | Promise used to return the next object in the result set.|
886
887**Error codes**
888
889For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
890
891| ID| Error Message                                                    |
892| -------- | ------------------------------------------------------------ |
893| 14000011 | Internal system error.                                        |
894
895**Example**
896
897```ts
898import { dataSharePredicates } from '@kit.ArkData';
899import { photoAccessHelper } from '@kit.MediaLibraryKit';
900
901async function example() {
902  console.info('getNextObjectDemo');
903  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
904  let fetchOption: photoAccessHelper.FetchOptions = {
905    fetchColumns: [],
906    predicates: predicates
907  };
908  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
909  await fetchResult.getFirstObject();
910  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getNextObject();
911  console.info('photoAsset displayName: ', photoAsset.displayName);
912}
913```
914
915### getLastObject
916
917getLastObject(): Promise&lt;T&gt;
918
919Obtains the last asset in the result set. This API uses a promise to return the result.
920
921**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
922
923**Return value**
924
925| Type            | Description                                   |
926| ---------------- | --------------------------------------- |
927| Promise&lt;T&gt; | Promise used to return the last object in the result set.|
928
929**Error codes**
930
931For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
932
933| ID| Error Message                                                    |
934| -------- | ------------------------------------------------------------ |
935| 14000011 | Internal system error.                                        |
936
937**Example**
938
939```ts
940import { dataSharePredicates } from '@kit.ArkData';
941import { photoAccessHelper } from '@kit.MediaLibraryKit';
942
943async function example() {
944  console.info('getLastObjectDemo');
945  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
946  let fetchOption: photoAccessHelper.FetchOptions = {
947    fetchColumns: [],
948    predicates: predicates
949  };
950  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
951  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
952  console.info('photoAsset displayName: ', photoAsset.displayName);
953}
954```
955
956### getObjectByPosition
957
958getObjectByPosition(index: number): Promise&lt;T&gt;
959
960Obtains the asset with the given index in the result set. This API uses a promise to return the result.
961
962**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
963
964**Parameters**
965
966| Name| Type  | Mandatory| Description                         |
967| ------ | ------ | ---- | ----------------------------- |
968| index  | number | Yes  | Index of the asset to obtain. The value starts from **0**.|
969
970**Return value**
971
972| Type            | Description                                         |
973| ---------------- | --------------------------------------------- |
974| Promise&lt;T&gt; | Promise used to return the asset obtained.|
975
976**Error codes**
977
978For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
979
980| ID| Error Message                                                    |
981| -------- | ------------------------------------------------------------ |
982| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
983| 14000011 | Internal system error.                                        |
984
985**Example**
986
987```ts
988import { dataSharePredicates } from '@kit.ArkData';
989import { photoAccessHelper } from '@kit.MediaLibraryKit';
990
991async function example() {
992  console.info('getObjectByPositionDemo');
993  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
994  let fetchOption: photoAccessHelper.FetchOptions = {
995    fetchColumns: [],
996    predicates: predicates
997  };
998  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
999  let photoAsset: sendablePhotoAccessHelper.PhotoAsset = await fetchResult.getObjectByPosition(0);
1000  console.info('photoAsset displayName: ', photoAsset.displayName);
1001}
1002```
1003
1004### getAllObjects
1005
1006getAllObjects(): Promise&lt;Array&lt;T&gt;&gt;
1007
1008Obtains all the file assets in the result set. This API uses a promise to return the result.
1009
1010**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1011
1012**Return value**
1013
1014| Type                         | Description                                       |
1015| ----------------------------- | ------------------------------------------- |
1016| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return all the assets in the result set.|
1017
1018**Error codes**
1019
1020For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1021
1022| ID| Error Message                                                    |
1023| -------- | ------------------------------------------------------------ |
1024| 14000011 | Internal system error.                                        |
1025
1026**Example**
1027
1028```ts
1029import { dataSharePredicates } from '@kit.ArkData';
1030import { photoAccessHelper } from '@kit.MediaLibraryKit';
1031
1032async function example() {
1033  console.info('getAllObjectDemo');
1034  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1035  let fetchOption: photoAccessHelper.FetchOptions = {
1036    fetchColumns: [],
1037    predicates: predicates
1038  };
1039  let fetchResult: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1040  let photoAssetList: Array<sendablePhotoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
1041  console.info('photoAssetList length: ', photoAssetList.length);
1042}
1043```
1044
1045## Album
1046
1047Provides APIs to manage albums.
1048
1049### Properties
1050
1051**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1052
1053| Name        | Type                         | Read-Only                        | Optional| Description            |
1054| ------------ | ----------------------------- | ---------------------------- | ---- | ---------------- |
1055| albumType    | [AlbumType](#albumtype)       | Yes                          | No  | Type of the album.      |
1056| albumSubtype | [AlbumSubtype](#albumsubtype) | Yes                          | No  | Subtype of the album.    |
1057| albumName    | string                        | Yes for a user album; no for a system album.| No  | Name of the album.      |
1058| albumUri     | string                        | Yes                          | No  | URI of the album.       |
1059| count        | number                        | Yes                          | No  | Number of files in the album.|
1060| coverUri     | string                        | Yes                          | No  | URI of the cover file of the album.   |
1061| imageCount   | number                        | Yes                          | Yes  | Number of images in the album.|
1062| videoCount   | number                        | Yes                          | Yes  | Number of videos in the album.|
1063
1064### convertToPhotoAlbum
1065
1066convertToPhotoAlbum(): photoAccessHelper.Album
1067
1068Converts this Sendable album to a non-Sendable album.
1069
1070**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1071
1072**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1073
1074| Type                   | Description                                                     |
1075| ----------------------- | --------------------------------------------------------- |
1076| [photoAccessHelper.Album](js-apis-photoAccessHelper.md#album) | Album of the non-Sendable type.|
1077
1078**Error codes**
1079
1080For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1081
1082| ID| Error Message                                                    |
1083| -------- | ------------------------------------------------------------ |
1084| 201      | Permission denied.                                           |
1085| 14000011 | Internal system error.                                        |
1086
1087**Example**
1088
1089```ts
1090import { dataSharePredicates } from '@kit.ArkData';
1091import { BusinessError } from '@kit.BasicServicesKit';
1092import { photoAccessHelper } from '@kit.MediaLibraryKit';
1093
1094async function example() {
1095  console.info('convertToPhotoAlbumDemo');
1096  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1097  let albumFetchOptions: photoAccessHelper.FetchOptions = {
1098    fetchColumns: [],
1099    predicates: predicates
1100  };
1101  let fetchOption: photoAccessHelper.FetchOptions = {
1102    fetchColumns: [],
1103    predicates: predicates
1104  };
1105  let albumList: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.Album> = await phAccessHelper.getAlbums(sendablePhotoAccessHelper.AlbumType.USER, sendablePhotoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
1106  let sendableAlbum: sendablePhotoAccessHelper.Album = await albumList.getFirstObject();
1107  let album: photoAccessHelper.Album = sendableAlbum.convertToPhotoAlbum();
1108  album.getAssets(fetchOption).then((albumFetchResult) => {
1109    console.info('convertToPhotoAlbum successfully, getCount: ' + albumFetchResult.getCount());
1110  }).catch((err: BusinessError) => {
1111    console.error(`convertToPhotoAlbum failed with error: ${err.code}, ${err.message}`);
1112  });
1113}
1114```
1115
1116### getAssets
1117
1118getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
1119
1120Obtains media assets. This API uses a promise to return the result.
1121
1122**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1123
1124**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1125
1126**Parameters**
1127
1128| Name | Type                                                     | Mandatory| Description      |
1129| ------- | --------------------------------------------------------- | ---- | ---------- |
1130| options | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes  | Options for fetching the albums.|
1131
1132**Return value**
1133
1134| Type                                                        | Description                                   |
1135| ------------------------------------------------------------ | --------------------------------------- |
1136| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the media assets obtained.|
1137
1138**Error codes**
1139
1140For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1141
1142| ID| Error Message                                                    |
1143| -------- | ------------------------------------------------------------ |
1144| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1145| 201      | Permission denied.                                           |
1146| 13900020 | Invalid argument.                                            |
1147| 14000011 | Internal system error.                                        |
1148
1149**Example**
1150
1151```ts
1152import { dataSharePredicates } from '@kit.ArkData';
1153import { BusinessError } from '@kit.BasicServicesKit';
1154import { photoAccessHelper } from '@kit.MediaLibraryKit';
1155
1156async function example() {
1157  console.info('albumGetAssetsDemoPromise');
1158  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1159  let albumFetchOptions: photoAccessHelper.FetchOptions = {
1160    fetchColumns: [],
1161    predicates: predicates
1162  };
1163  let fetchOption: photoAccessHelper.FetchOptions = {
1164    fetchColumns: [],
1165    predicates: predicates
1166  };
1167  let albumList: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.Album> = await phAccessHelper.getAlbums(sendablePhotoAccessHelper.AlbumType.USER, sendablePhotoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
1168  let album: sendablePhotoAccessHelper.Album = await albumList.getFirstObject();
1169  album.getAssets(fetchOption).then((albumFetchResult) => {
1170    console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
1171  }).catch((err: BusinessError) => {
1172    console.error(`album getAssets failed with error: ${err.code}, ${err.message}`);
1173  });
1174}
1175```
1176
1177### commitModify
1178
1179commitModify(): Promise&lt;void&gt;
1180
1181Commits the modification on the album attributes to the database. This API uses a promise to return the result.
1182
1183**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1184
1185**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1186
1187**Return value**
1188
1189| Type               | Description                   |
1190| ------------------- | ----------------------- |
1191| Promise&lt;void&gt; | Promise that returns no value.|
1192
1193**Error codes**
1194
1195For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1196
1197| ID| Error Message                                                    |
1198| -------- | ------------------------------------------------------------ |
1199| 201      | Permission denied.                                           |
1200| 14000011 | Internal system error.                                        |
1201
1202**Example**
1203
1204```ts
1205import { dataSharePredicates } from '@kit.ArkData';
1206import { BusinessError } from '@kit.BasicServicesKit';
1207import { photoAccessHelper } from '@kit.MediaLibraryKit';
1208
1209async function example() {
1210  console.info('albumCommitModifyDemo');
1211  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1212  let albumFetchOptions: photoAccessHelper.FetchOptions = {
1213    fetchColumns: [],
1214    predicates: predicates
1215  };
1216  let albumList: sendablePhotoAccessHelper.FetchResult<sendablePhotoAccessHelper.Album> = await phAccessHelper.getAlbums(sendablePhotoAccessHelper.AlbumType.USER, sendablePhotoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
1217  let album: sendablePhotoAccessHelper.Album = await albumList.getFirstObject();
1218  album.albumName = 'hello';
1219  album.commitModify().then(() => {
1220    console.info('commitModify successfully');
1221  }).catch((err: BusinessError) => {
1222    console.error(`commitModify failed with error: ${err.code}, ${err.message}`);
1223  });
1224}
1225```
1226
1227## PhotoType
1228
1229Enumerates media file types.
1230
1231**Atomic service API**: This API can be used in atomic services since API version 12.
1232
1233**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1234
1235| Name | Value  | Description  |
1236| ----- | ---- | ------ |
1237| IMAGE | 1    | Image.|
1238| VIDEO | 2    | Video.|
1239
1240## PhotoSubtype<sup>14+</sup>
1241
1242Enumerates the [PhotoAsset](#photoasset) types.
1243
1244**Atomic service API**: This API can be used in atomic services since API version 14.
1245
1246**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1247
1248| Name |  Value|  Description|
1249| ----- |  ---- |  ---- |
1250| DEFAULT |  0 |  Photo, which is the default type.|
1251| MOVING_PHOTO |  3 |  Moving photo.|
1252| BURST |  4 |  Burst photo.|
1253
1254## DynamicRangeType<sup>14+</sup>
1255
1256Enumerates the dynamic range types of media assets.
1257
1258**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1259
1260| Name |  Value|  Description|
1261| ----- |  ---- |  ---- |
1262| SDR |  0 |  Standard dynamic range (SDR).|
1263| HDR |  1 |  High dynamic range (HDR). |
1264
1265## AlbumType
1266
1267Enumerates the album types.
1268
1269**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1270
1271| Name  | Value  | Description          |
1272| ------ | ---- | -------------- |
1273| USER   | 0    | User album.    |
1274| SYSTEM | 1024 | System album.|
1275
1276## AlbumSubtype
1277
1278Enumerate the album subtypes.
1279
1280**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1281
1282| Name         | Value        | Description      |
1283| ------------- | ---------- | ---------- |
1284| USER\_GENERIC | 1          | User album.|
1285| FAVORITE      | 1025       | Favorites.  |
1286| VIDEO         | 1026       | Video album.|
1287| IMAGE         | 1031       | Photo album.|
1288| ANY           | 2147483647 | Any album.|
1289