• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.filemanagement.userFileManager (User Data Management)
2
3The **userFileManager** module provides user data management capabilities, including accessing and modifying user media data (audio and video clips, images, and files).
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import userFileManager from '@ohos.filemanagement.userFileManager';
14```
15
16## userFileManager.getUserFileMgr
17
18getUserFileMgr(context: Context): UserFileManager
19
20Obtains a **UserFileManager** instance. This instance can be used to access and modify user media data (such as audio and video clips, images, and files).
21
22**Model restriction**: This API can be used only in the stage model.
23
24**System capability**: SystemCapability.FileManagement.UserFileManager.Core
25
26**Parameters**
27
28| Name | Type   | Mandatory| Description                      |
29| ------- | ------- | ---- | -------------------------- |
30| context | [Context](js-apis-inner-app-context.md) | Yes  | Context of the ability instance.|
31
32**Return value**
33
34| Type                           | Description   |
35| ----------------------------- | :---- |
36| [UserFileManager](#userfilemanager) | **UserFileManager** instance obtained.|
37
38**Example**
39
40```ts
41// The userFileManager 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 mgr is not defined.
42const context = getContext(this);
43let mgr = userFileManager.getUserFileMgr(context);
44```
45
46## UserFileManager
47
48### getPhotoAssets
49
50getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
51
52Obtains image and video assets. This API uses an asynchronous callback to return the result.
53
54**System capability**: SystemCapability.FileManagement.UserFileManager.Core
55
56**Required permissions**: ohos.permission.READ_IMAGEVIDEO
57
58**Parameters**
59
60| Name  | Type                    | Mandatory| Description                     |
61| -------- | ------------------------ | ---- | ------------------------- |
62| options  | [FetchOptions](#fetchoptions)        | Yes  | Options for fetching the image and video assets.             |
63| callback |  AsyncCallback<[FetchResult](#fetchresult)<[FileAsset](#fileasset)>> | Yes  | Callback invoked to return the image and video assets obtained.|
64
65**Error codes**
66
67For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
68
69| ID| Error Message|
70| -------- | ---------------------------------------- |
71| 13900020   | if type options is not FetchOptions.         |
72
73**Example**
74
75```ts
76import dataSharePredicates from '@ohos.data.dataSharePredicates';
77
78async function example() {
79  console.info('getPhotoAssets');
80  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
81  let fetchOptions: userFileManager.FetchOptions = {
82    fetchColumns: [],
83    predicates: predicates
84  };
85
86  mgr.getPhotoAssets(fetchOptions, async (err, fetchResult) => {
87    if (fetchResult != undefined) {
88      console.info('fetchResult success');
89      let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
90      if (fileAsset != undefined) {
91        console.info('fileAsset.displayName : ' + fileAsset.displayName);
92      }
93    } else {
94      console.error('fetchResult fail' + err);
95    }
96  });
97}
98```
99
100### getPhotoAssets
101
102getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
103
104Obtains image and video assets. This API uses a promise to return the result.
105
106**System capability**: SystemCapability.FileManagement.UserFileManager.Core
107
108**Required permissions**: ohos.permission.READ_IMAGEVIDEO
109
110**Parameters**
111
112| Name | Type               | Mandatory| Description            |
113| ------- | ------------------- | ---- | ---------------- |
114| options | [FetchOptions](#fetchoptions)   | Yes  | Options for fetching the image and video assets.    |
115
116**Return value**
117
118| Type                       | Description          |
119| --------------------------- | -------------- |
120| Promise<[FetchResult](#fetchresult)<[FileAsset](#fileasset)>> | Promise used to return the image and video assets obtained.|
121
122**Error codes**
123
124For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
125
126| ID| Error Message|
127| -------- | ---------------------------------------- |
128| 13900020   | if type options is not FetchOptions.         |
129
130**Example**
131
132```ts
133import dataSharePredicates from '@ohos.data.dataSharePredicates';
134
135async function example() {
136  console.info('getPhotoAssets');
137  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
138  let fetchOptions: userFileManager.FetchOptions = {
139    fetchColumns: [],
140    predicates: predicates
141  };
142  try {
143    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
144    if (fetchResult != undefined) {
145      console.info('fetchResult success');
146      let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
147      if (fileAsset != undefined) {
148        console.info('fileAsset.displayName :' + fileAsset.displayName);
149      }
150    }
151  } catch (err) {
152    console.error('getPhotoAssets failed, message = ', err);
153  }
154}
155```
156### createPhotoAsset
157
158createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback&lt;FileAsset&gt;): void;
159
160Creates an image or video asset with the specified file name and URI. This API uses an asynchronous callback to return the result.
161
162**System capability**: SystemCapability.FileManagement.UserFileManager.Core
163
164**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
165
166**Parameters**
167
168| Name  | Type                    | Mandatory| Description                     |
169| -------- | ------------------------ | ---- | ------------------------- |
170| displayName  | string        | Yes  | File name of the image or video to create.             |
171| albumUri  | string        | Yes  | URI of the album where the image or video is located.             |
172| callback |  AsyncCallback&lt;[FileAsset](#fileasset)&gt; | Yes  | Callback invoked to return the image or video created.|
173
174**Error codes**
175
176For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
177
178| ID| Error Message|
179| -------- | ---------------------------------------- |
180| 13900020   | if type displayName or albumUri is not string.         |
181| 14000001   | if type displayName invalid.         |
182
183**Example**
184
185```ts
186import dataSharePredicates from '@ohos.data.dataSharePredicates';
187
188async function example() {
189  console.info('createPhotoAssetDemo');
190  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
191  let fetchOptions: userFileManager.AlbumFetchOptions = {
192    predicates: predicates
193  };
194  let albums: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(fetchOptions);
195  let album: userFileManager.Album = await albums.getFirstObject();
196  let testFileName: string = 'testFile' + Date.now() + '.jpg';
197  mgr.createPhotoAsset(testFileName, album.albumUri, (err, fileAsset) => {
198    if (fileAsset != undefined) {
199      console.info('createPhotoAsset file displayName' + fileAsset.displayName);
200      console.info('createPhotoAsset successfully');
201    } else {
202      console.error('createPhotoAsset failed, message = ', err);
203    }
204  });
205}
206```
207
208### createPhotoAsset
209
210createPhotoAsset(displayName: string, callback: AsyncCallback&lt;FileAsset&gt;): void;
211
212Creates an image or video asset with the specified file name. This API uses an asynchronous callback to return the result.
213
214**System capability**: SystemCapability.FileManagement.UserFileManager.Core
215
216**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
217
218**Parameters**
219
220| Name  | Type                    | Mandatory| Description                     |
221| -------- | ------------------------ | ---- | ------------------------- |
222| displayName  | string        | Yes  | File name of the image or video to create.             |
223| callback |  AsyncCallback&lt;[FileAsset](#fileasset)&gt; | Yes  | Callback invoked to return the image or video asset created. |
224
225**Error codes**
226
227For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
228
229| ID| Error Message|
230| -------- | ---------------------------------------- |
231| 13900020   | if type displayName is not string.         |
232| 14000001   | if type displayName invalid.         |
233
234**Example**
235
236```ts
237async function example() {
238  console.info('createPhotoAssetDemo');
239  let testFileName: string = 'testFile' + Date.now() + '.jpg';
240  mgr.createPhotoAsset(testFileName, (err, fileAsset) => {
241    if (fileAsset != undefined) {
242      console.info('createPhotoAsset file displayName' + fileAsset.displayName);
243      console.info('createPhotoAsset successfully');
244    } else {
245      console.error('createPhotoAsset failed, message = ', err);
246    }
247  });
248}
249```
250
251### createPhotoAsset
252
253createPhotoAsset(displayName: string, albumUri?: string): Promise&lt;FileAsset&gt;;
254
255Creates an image or video asset with the specified file name and URI. This API uses a promise to return the result.
256
257**System capability**: SystemCapability.FileManagement.UserFileManager.Core
258
259**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
260
261**Parameters**
262
263| Name  | Type                    | Mandatory| Description                     |
264| -------- | ------------------------ | ---- | ------------------------- |
265| displayName  | string        | Yes  | File name of the image or video to create.             |
266| albumUri  | string        | No  | URI of the album where the image or video is located.             |
267
268**Return value**
269
270| Type                       | Description          |
271| --------------------------- | -------------- |
272| Promise&lt;[FileAsset](#fileasset)&gt; | Promise used to return the created image or video asset created. |
273
274**Error codes**
275
276For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
277
278| ID| Error Message|
279| -------- | ---------------------------------------- |
280| 13900020   | if type displayName or albumUri is not string.         |
281
282**Example**
283
284```ts
285async function example() {
286  console.info('createPhotoAssetDemo');
287  try {
288    let testFileName: string = 'testFile' + Date.now() + '.jpg';
289    let fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName);
290    console.info('createPhotoAsset file displayName' + fileAsset.displayName);
291    console.info('createPhotoAsset successfully');
292  } catch (err) {
293    console.error('createPhotoAsset failed, message = ', err);
294  }
295}
296```
297
298### createPhotoAsset
299
300createPhotoAsset(displayName: string, createOption: PhotoCreateOptions, callback: AsyncCallback&lt;FileAsset&gt;): void;
301
302Creates an image or video asset with the specified file name and options. This API uses an asynchronous callback to return the result.
303
304**System capability**: SystemCapability.FileManagement.UserFileManager.Core
305
306**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
307
308**Parameters**
309
310| Name  | Type                    | Mandatory| Description                     |
311| -------- | ------------------------ | ---- | ------------------------- |
312| displayName  | string        | Yes  | File name of the image or video to create.             |
313| createOption  | [PhotoCreateOptions](#photocreateoptions10)        | Yes  | Options for creating an image or video asset.             |
314| callback |  AsyncCallback&lt;[FileAsset](#fileasset)&gt; | Yes  | Callback invoked to return the image or video created.|
315
316**Error codes**
317
318For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
319
320| ID| Error Message|
321| -------- | ---------------------------------------- |
322| 13900020   | if type displayName is not string.         |
323| 14000001   | if type displayName invalid.         |
324
325**Example**
326
327```ts
328async function example() {
329  console.info('createPhotoAssetDemo');
330  let testFileName: string = 'testFile' + Date.now() + '.jpg';
331  let createOption: userFileManager.PhotoCreateOptions = {
332    subType: userFileManager.PhotoSubType.DEFAULT
333  }
334  mgr.createPhotoAsset(testFileName, createOption, (err, fileAsset) => {
335    if (fileAsset != undefined) {
336      console.info('createPhotoAsset file displayName' + fileAsset.displayName);
337      console.info('createPhotoAsset successfully');
338    } else {
339      console.error('createPhotoAsset failed, message = ', err);
340    }
341  });
342}
343```
344
345### createPhotoAsset
346
347createPhotoAsset(displayName: string, createOption: PhotoCreateOptions): Promise&lt;FileAsset&gt;;
348
349Creates an image or video asset with the specified file name and options. This API uses a promise to return the result.
350
351**System capability**: SystemCapability.FileManagement.UserFileManager.Core
352
353**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
354
355**Parameters**
356
357| Name  | Type                    | Mandatory| Description                     |
358| -------- | ------------------------ | ---- | ------------------------- |
359| displayName  | string        | Yes  | File name of the image or video to create.             |
360| createOption  |  [PhotoCreateOptions](#photocreateoptions10)       | Yes  | Options for creating an image or video asset.             |
361
362**Return value**
363
364| Type                       | Description          |
365| --------------------------- | -------------- |
366| Promise&lt;[FileAsset](#fileasset)&gt; | Promise used to return the created image or video asset created. |
367
368**Error codes**
369
370For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
371
372| ID| Error Message|
373| -------- | ---------------------------------------- |
374| 13900020   | if type displayName is not string.         |
375
376**Example**
377
378```ts
379async function example() {
380  console.info('createPhotoAssetDemo');
381  try {
382    let testFileName: string = 'testFile' + Date.now() + '.jpg';
383    let createOption: userFileManager.PhotoCreateOptions = {
384      subType: userFileManager.PhotoSubType.DEFAULT
385    }
386    let fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName, createOption);
387    console.info('createPhotoAsset file displayName' + fileAsset.displayName);
388    console.info('createPhotoAsset successfully');
389  } catch (err) {
390    console.error('createPhotoAsset failed, message = ', err);
391  }
392}
393```
394
395### createAudioAsset<sup>10+</sup>
396
397createAudioAsset(displayName: string, callback: AsyncCallback&lt;FileAsset&gt;): void;
398
399Creates an audio asset. This API uses an asynchronous callback to return the result.
400
401**System capability**: SystemCapability.FileManagement.UserFileManager.Core
402
403**Required permissions**: ohos.permission.WRITE_AUDIO
404
405**Parameters**
406
407| Name  | Type                    | Mandatory| Description                     |
408| -------- | ------------------------ | ---- | ------------------------- |
409| displayName  | string        | Yes  | File name of the audio asset to create.             |
410| callback |  AsyncCallback&lt;[FileAsset](#fileasset)&gt; | Yes  | Callback invoked to return the created audio asset.|
411
412**Error codes**
413
414For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
415
416| ID| Error Message|
417| -------- | ---------------------------------------- |
418| 13900020   | if type displayName is not string.         |
419| 14000001   | if type displayName invalid.         |
420
421**Example**
422
423```ts
424async function example() {
425  console.info('createAudioAssetDemo');
426  let testFileName: string = 'testFile' + Date.now() + '.mp3';
427  mgr.createAudioAsset(testFileName, (err, fileAsset) => {
428    if (fileAsset != undefined) {
429      console.info('createAudioAsset file displayName' + fileAsset.displayName);
430      console.info('createAudioAsset successfully');
431    } else {
432      console.error('createAudioAsset failed, message = ', err);
433    }
434  });
435}
436```
437
438### createAudioAsset<sup>10+</sup>
439
440createAudioAsset(displayName: string): Promise&lt;FileAsset&gt;;
441
442Creates an audio asset. This API uses a promise to return the result.
443
444**System capability**: SystemCapability.FileManagement.UserFileManager.Core
445
446**Required permissions**: ohos.permission.WRITE_AUDIO
447
448**Parameters**
449
450| Name  | Type                    | Mandatory| Description                     |
451| -------- | ------------------------ | ---- | ------------------------- |
452| displayName  | string        | Yes  | File name of the audio asset to create.             |
453
454**Return value**
455
456| Type                       | Description          |
457| --------------------------- | -------------- |
458| Promise&lt;[FileAsset](#fileasset)&gt; | Promise used to return the created audio asset.|
459
460**Error codes**
461
462For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
463
464| ID| Error Message|
465| -------- | ---------------------------------------- |
466| 13900020   | if type displayName is not string.         |
467
468**Example**
469
470```ts
471async function example() {
472  console.info('createAudioAssetDemo');
473  try {
474    let testFileName: string = 'testFile' + Date.now() + '.mp3';
475    let fileAsset: userFileManager.FileAsset = await mgr.createAudioAsset(testFileName);
476    console.info('createAudioAsset file displayName' + fileAsset.displayName);
477    console.info('createAudioAsset successfully');
478  } catch (err) {
479    console.error('createAudioAsset failed, message = ', err);
480  }
481}
482```
483
484### createAlbum<sup>10+</sup>
485
486createAlbum(name: string, callback: AsyncCallback&lt;Album&gt;): void;
487
488Creates an album. This API uses an asynchronous callback to return the result.
489
490The album name must meet the following requirements:
491- The album name is a string of 1 to 255 characters.
492- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
493- The album name is case-insensitive.
494- Duplicate album names are not allowed.
495
496**System capability**: SystemCapability.FileManagement.UserFileManager.Core
497
498**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
499
500**Parameters**
501
502| Name  | Type                    | Mandatory| Description                     |
503| -------- | ------------------------ | ---- | ------------------------- |
504| name  | string         | Yes  | Name of the album to create.             |
505| callback |  AsyncCallback&lt;[Album](#album)&gt; | Yes  | Callback invoked to return the created album instance.|
506
507**Example**
508
509```ts
510async function example() {
511  console.info('createAlbumDemo');
512  let albumName: string = 'newAlbumName' + new Date().getTime();
513  mgr.createAlbum(albumName, (err, album) => {
514    if (err) {
515      console.error('createAlbumCallback failed with err: ' + err);
516      return;
517    }
518    console.info('createAlbumCallback successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
519  });
520}
521```
522
523### createAlbum<sup>10+</sup>
524
525createAlbum(name: string): Promise&lt;Album&gt;;
526
527Creates an album. This API uses a promise to return the result.
528
529The album name must meet the following requirements:
530- The album name is a string of 1 to 255 characters.
531- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ]
532- The album name is case-insensitive.
533- Duplicate album names are not allowed.
534
535**System capability**: SystemCapability.FileManagement.UserFileManager.Core
536
537**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
538
539**Parameters**
540
541| Name  | Type                    | Mandatory| Description                     |
542| -------- | ------------------------ | ---- | ------------------------- |
543| name  | string         | Yes  | Name of the album to create.             |
544
545**Return value**
546
547| Type                       | Description          |
548| --------------------------- | -------------- |
549| Promise&lt;[Album](#album)&gt; | Promise used to return the created album instance.|
550
551**Example**
552
553```ts
554import { BusinessError } from '@ohos.base';
555
556async function example() {
557  console.info('createAlbumDemo');
558  let albumName: string  = 'newAlbumName' + new Date().getTime();
559  mgr.createAlbum(albumName).then((album) => {
560    console.info('createAlbumPromise successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
561  }).catch((err: BusinessError) => {
562    console.error('createAlbumPromise failed with err: ' + err);
563  });
564}
565```
566
567### deleteAlbums<sup>10+</sup>
568
569deleteAlbums(albums: Array&lt;Album&gt;, callback: AsyncCallback&lt;void&gt;): void;
570
571Deletes albums. This API uses an asynchronous callback to return the result.
572
573Ensure that the albums to be deleted exist. Only user albums can be deleted.
574
575**System capability**: SystemCapability.FileManagement.UserFileManager.Core
576
577**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
578
579**Parameters**
580
581| Name  | Type                    | Mandatory| Description                     |
582| -------- | ------------------------ | ---- | ------------------------- |
583| albums  | Array&lt;[Album](#album)&gt;         | Yes  | Albums to delete.             |
584| callback |  AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
585
586**Example**
587
588```ts
589import dataSharePredicates from '@ohos.data.dataSharePredicates';
590
591async function example() {
592  // Delete the album named newAlbumName.
593  console.info('deleteAlbumsDemo');
594  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
595  predicates.equalTo('album_name', 'newAlbumName');
596  let fetchOptions: userFileManager.FetchOptions = {
597    fetchColumns: [],
598    predicates: predicates
599  };
600  let fetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC, fetchOptions);
601  let album: userFileManager.Album = await fetchResult.getFirstObject();
602  mgr.deleteAlbums([album], (err) => {
603    if (err) {
604      console.error('deletePhotoAlbumsCallback failed with err: ' + err);
605      return;
606    }
607    console.info('deletePhotoAlbumsCallback successfully');
608  });
609  fetchResult.close();
610}
611```
612
613### deleteAlbums<sup>10+</sup>
614
615deleteAlbums(albums: Array&lt;Album&gt;): Promise&lt;void&gt;;
616
617Deletes albums. This API uses a promise to return the result.
618
619Ensure that the albums to be deleted exist. Only user albums can be deleted.
620
621**System capability**: SystemCapability.FileManagement.UserFileManager.Core
622
623**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
624
625**Parameters**
626
627| Name  | Type                    | Mandatory| Description                     |
628| -------- | ------------------------ | ---- | ------------------------- |
629| albums  |  Array&lt;[Album](#album)&gt;          | Yes  | Albums to delete.             |
630
631**Return value**
632
633| Type                       | Description          |
634| --------------------------- | -------------- |
635| Promise&lt;void&gt; | Promise that returns no value.|
636
637**Example**
638
639```ts
640import dataSharePredicates from '@ohos.data.dataSharePredicates';
641import { BusinessError } from '@ohos.base';
642
643async function example() {
644  // Delete the album named newAlbumName.
645  console.info('deleteAlbumsDemo');
646  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
647  predicates.equalTo('album_name', 'newAlbumName');
648  let fetchOptions: userFileManager.FetchOptions = {
649    fetchColumns: [],
650    predicates: predicates
651  };
652  let fetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC, fetchOptions);
653  let album: userFileManager.Album = await fetchResult.getFirstObject();
654  mgr.deleteAlbums([album]).then(() => {
655    console.info('deletePhotoAlbumsPromise successfully');
656    }).catch((err: BusinessError) => {
657      console.error('deletePhotoAlbumsPromise failed with err: ' + err);
658  });
659  fetchResult.close();
660}
661```
662
663### getAlbums<sup>10+</sup>
664
665getAlbums(type: AlbumType, subType: AlbumSubType, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void;
666
667Obtain albums based on the specified options and album type. This API uses an asynchronous callback to return the result.
668
669Before the operation, ensure that the albums to obtain exist.
670
671**System capability**: SystemCapability.FileManagement.UserFileManager.Core
672
673**Required permissions**: ohos.permission.READ_IMAGEVIDEO
674
675**Parameters**
676
677| Name  | Type                    | Mandatory| Description                     |
678| -------- | ------------------------ | ---- | ------------------------- |
679| type  | [AlbumType](#albumtype10)         | Yes  | Type of the album to obtain.             |
680| subType  | [AlbumSubType](#albumsubtype10)         | Yes  | Subtype of the album.             |
681| options  | [FetchOptions](#fetchoptions)         | Yes  |  Options for fetching the albums.             |
682| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
683
684**Error codes**
685
686For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
687
688| ID| Error Message|
689| -------- | ---------------------------------------- |
690| 13900020   | if type options is not FetchOption.         |
691
692**Example**
693
694```ts
695import dataSharePredicates from '@ohos.data.dataSharePredicates';
696
697async function example() {
698  // Obtain the album named newAlbumName.
699  console.info('getAlbumsDemo');
700  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
701  predicates.equalTo('album_name', 'newAlbumName');
702  let fetchOptions: userFileManager.FetchOptions = {
703    fetchColumns: [],
704    predicates: predicates
705  };
706  mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC, fetchOptions, async (err, fetchResult) => {
707    if (err) {
708      console.error('getAlbumsCallback failed with err: ' + err);
709      return;
710    }
711    if (fetchResult == undefined) {
712      console.error('getAlbumsCallback fetchResult is undefined');
713      return;
714    }
715    let album: userFileManager.Album = await fetchResult.getFirstObject();
716    console.info('getAlbumsCallback successfully, albumName: ' + album.albumName);
717    fetchResult.close();
718  });
719}
720```
721
722### getAlbums<sup>10+</sup>
723
724getAlbums(type: AlbumType, subType: AlbumSubType, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void;
725
726Obtains albums by type. This API uses an asynchronous callback to return the result.
727
728Before the operation, ensure that the albums to obtain exist.
729
730**System capability**: SystemCapability.FileManagement.UserFileManager.Core
731
732**Required permissions**: ohos.permission.READ_IMAGEVIDEO
733
734**Parameters**
735
736| Name  | Type                    | Mandatory| Description                     |
737| -------- | ------------------------ | ---- | ------------------------- |
738| type  | [AlbumType](#albumtype10)         | Yes  | Type of the album to obtain.             |
739| subType  | [AlbumSubType](#albumsubtype10)         | Yes  | Subtype of the album.             |
740| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the result.|
741
742**Error codes**
743
744For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
745
746| ID| Error Message|
747| -------- | ---------------------------------------- |
748| 13900020   | if type options is not FetchOption.         |
749
750**Example**
751
752```ts
753async function example() {
754  // Obtain the system album VIDEO, which is preset by default.
755  console.info('getAlbumsDemo');
756  mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.VIDEO, async (err, fetchResult) => {
757    if (err) {
758      console.error('getAlbumsCallback failed with err: ' + err);
759      return;
760    }
761    if (fetchResult == undefined) {
762      console.error('getAlbumsCallback fetchResult is undefined');
763      return;
764    }
765    let album: userFileManager.Album = await fetchResult.getFirstObject();
766    console.info('getAlbumsCallback successfully, albumUri: ' + album.albumUri);
767    fetchResult.close();
768  });
769}
770```
771
772### getAlbums<sup>10+</sup>
773
774getAlbums(type: AlbumType, subType: AlbumSubType, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;;
775
776Obtain albums based on the specified options and album type. This API uses a promise to return the result.
777
778Before the operation, ensure that the albums to obtain exist.
779
780**System capability**: SystemCapability.FileManagement.UserFileManager.Core
781
782**Required permissions**: ohos.permission.READ_IMAGEVIDEO
783
784**Parameters**
785
786| Name  | Type                    | Mandatory| Description                     |
787| -------- | ------------------------ | ---- | ------------------------- |
788| type  | [AlbumType](#albumtype10)         | Yes  | Type of the album to obtain.             |
789| subType  | [AlbumSubType](#albumsubtype10)         | Yes  | Subtype of the album.             |
790| 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.             |
791
792**Return value**
793
794| Type                       | Description          |
795| --------------------------- | -------------- |
796| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.|
797
798**Error codes**
799
800For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
801
802| ID| Error Message|
803| -------- | ---------------------------------------- |
804| 13900020   | if type options is not FetchOption.         |
805
806**Example**
807
808```ts
809import dataSharePredicates from '@ohos.data.dataSharePredicates';
810import { BusinessError } from '@ohos.base';
811
812async function example() {
813  // Obtain the album named newAlbumName.
814  console.info('getAlbumsDemo');
815  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
816  predicates.equalTo('album_name', 'newAlbumName');
817  let fetchOptions: userFileManager.FetchOptions = {
818    fetchColumns: [],
819    predicates: predicates
820  };
821  mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC, fetchOptions).then( async (fetchResult) => {
822    if (fetchResult == undefined) {
823      console.error('getAlbumsPromise fetchResult is undefined');
824      return;
825    }
826    let album: userFileManager.Album = await fetchResult.getFirstObject();
827    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
828    fetchResult.close();
829  }).catch((err: BusinessError) => {
830    console.error('getAlbumsPromise failed with err: ' + err);
831  });
832}
833```
834
835### getPhotoAlbums
836
837getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void;
838
839Obtains image and video albums. This API uses an asynchronous callback to return the result.
840
841This API will be deprecated. Use [getAlbums<sup>10+</sup>](#getalbums10) instead.
842
843**System capability**: SystemCapability.FileManagement.UserFileManager.Core
844
845**Required permissions**: ohos.permission.READ_IMAGEVIDEO
846
847**Parameters**
848
849| Name  | Type                    | Mandatory| Description                     |
850| -------- | ------------------------ | ---- | ------------------------- |
851| options  | [AlbumFetchOptions](#albumfetchoptions)        | Yes  | Options for fetching the albums.             |
852| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback invoked to return the image and video albums obtained.|
853
854**Error codes**
855
856For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
857
858| ID| Error Message|
859| -------- | ---------------------------------------- |
860| 13900020   | if type options is not AlbumFetchOptions.         |
861
862**Example**
863
864```ts
865import dataSharePredicates from '@ohos.data.dataSharePredicates';
866
867async function example() {
868  console.info('getPhotoAlbumsDemo');
869  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
870  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
871    predicates: predicates
872  };
873
874  mgr.getPhotoAlbums(albumFetchOptions, (err, fetchResult) => {
875    if (fetchResult != undefined) {
876      console.info('albums.count = ' + fetchResult.getCount());
877      fetchResult.getFirstObject((err, album) => {
878        if (album != undefined) {
879          console.info('first album.albumName = ' + album.albumName);
880        } else {
881          console.error('album is undefined, err = ', err);
882        }
883      });
884    } else {
885      console.error('getPhotoAlbums fail, message = ', err);
886    }
887  });
888}
889```
890
891### getPhotoAlbums
892
893getPhotoAlbums(options: AlbumFetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;;
894
895Obtains image and video albums. This API uses a promise to return the result.
896
897This API will be deprecated. Use [getAlbums<sup>10+</sup>](#getalbums10) instead.
898
899**System capability**: SystemCapability.FileManagement.UserFileManager.Core
900
901**Required permissions**: ohos.permission.READ_IMAGEVIDEO
902
903**Parameters**
904
905| Name  | Type                    | Mandatory| Description                     |
906| -------- | ------------------------ | ---- | ------------------------- |
907| options  | [AlbumFetchOptions](#albumfetchoptions)        | Yes  | Options for fetching the albums.             |
908
909**Return value**
910
911| Type                       | Description          |
912| --------------------------- | -------------- |
913| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the image and video albums obtained.|
914
915**Error codes**
916
917For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
918
919| ID| Error Message|
920| -------- | ---------------------------------------- |
921| 13900020   | if type options is not AlbumFetchOptions.         |
922
923**Example**
924
925```ts
926import dataSharePredicates from '@ohos.data.dataSharePredicates';
927
928async function example() {
929  console.info('getPhotoAlbumsDemo');
930  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
931  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
932    predicates: predicates
933  };
934  try {
935    let fetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(albumFetchOptions);
936    console.info('album.count = ' + fetchResult.getCount());
937    const album: userFileManager.Album = await fetchResult.getFirstObject();
938    console.info('first album.albumName = ' + album.albumName);
939  } catch (err) {
940    console.error('getPhotoAlbums fail, message = ' + err);
941  }
942}
943```
944
945### getPrivateAlbum
946
947getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback&lt;FetchResult&lt;PrivateAlbum&gt;&gt;): void;
948
949Obtains the system album. This API uses an asynchronous callback to return the result.
950
951This API will be deprecated. Use [getAlbums<sup>10+</sup>](#getalbums10) instead.
952
953**System capability**: SystemCapability.FileManagement.UserFileManager.Core
954
955**Required permissions**: ohos.permission.READ_IMAGEVIDEO
956
957**Parameters**
958
959| Name  | Type                    | Mandatory| Description                     |
960| -------- | ------------------------ | ---- | ------------------------- |
961| type  | [PrivateAlbumType](#privatealbumtype)        | Yes  | Type of the system album to obtain.             |
962| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[PrivateAlbum](#privatealbum)&gt;&gt; | Yes  | Callback invoked to return the album obtained.|
963
964**Error codes**
965
966For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
967
968| ID| Error Message|
969| -------- | ---------------------------------------- |
970| 13900020   | if type type is not PrivateAlbumType.         |
971
972**Example**
973
974```ts
975async function example() {
976  console.info('getPrivateAlbumDemo');
977  mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH, async (err, fetchResult) => {
978    if (fetchResult != undefined) {
979      let trashAlbum: userFileManager.PrivateAlbum = await fetchResult.getFirstObject();
980      console.info('first album.albumName = ' + trashAlbum.albumName);
981    } else {
982      console.error('getPrivateAlbum failed. message = ', err);
983    }
984  });
985}
986```
987
988### getPrivateAlbum
989
990getPrivateAlbum(type: PrivateAlbumType): Promise&lt;FetchResult&lt;PrivateAlbum&gt;&gt;;
991
992Obtains the system album. This API uses a promise to return the result.
993
994This API will be deprecated. Use [getAlbums<sup>10+</sup>](#getalbums10) instead.
995
996**System capability**: SystemCapability.FileManagement.UserFileManager.Core
997
998**Required permissions**: ohos.permission.READ_IMAGEVIDEO
999
1000**Parameters**
1001
1002| Name  | Type                    | Mandatory| Description                     |
1003| -------- | ------------------------ | ---- | ------------------------- |
1004| type  | [PrivateAlbumType](#privatealbumtype)        | Yes  | Type of the system album to obtain.             |
1005
1006**Return value**
1007
1008| Type                       | Description          |
1009| --------------------------- | -------------- |
1010| Promise&lt;[FetchResult](#fetchresult)&lt;[PrivateAlbum](#privatealbum)&gt;&gt; | Promise used to return the system album obtained.|
1011
1012**Error codes**
1013
1014For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1015
1016| ID| Error Message|
1017| -------- | ---------------------------------------- |
1018| 13900020   | if type type is not PrivateAlbumType.         |
1019
1020**Example**
1021
1022```ts
1023async function example() {
1024  console.info('getPrivateAlbumDemo');
1025  try {
1026    let fetchResult: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
1027    let trashAlbum: userFileManager.PrivateAlbum = await fetchResult.getFirstObject();
1028    console.info('first album.albumName = ' + trashAlbum.albumName);
1029  } catch (err) {
1030    console.error('getPrivateAlbum failed. message = ', err);
1031  }
1032}
1033```
1034
1035### getAudioAssets
1036
1037getAudioAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
1038
1039Obtains audio assets. This API uses an asynchronous callback to return the result.
1040
1041**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1042
1043**Required permissions**: ohos.permission.READ_AUDIO
1044
1045**Parameters**
1046
1047| Name  | Type                    | Mandatory| Description                     |
1048| -------- | ------------------------ | ---- | ------------------------- |
1049| options  | [FetchOptions](#fetchoptions)        | Yes  | Options for fetching the audio assets.             |
1050| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;&gt; | Yes  | Callback invoked to return the audio assets obtained.|
1051
1052**Error codes**
1053
1054For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1055
1056| ID| Error Message|
1057| -------- | ---------------------------------------- |
1058| 13900020   | if type options is not FetchOptions.         |
1059
1060**Example**
1061
1062```ts
1063import dataSharePredicates from '@ohos.data.dataSharePredicates';
1064
1065async function example() {
1066  console.info('getAudioAssets');
1067  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1068  let fetchOptions: userFileManager.FetchOptions = {
1069    fetchColumns: [],
1070    predicates: predicates
1071  };
1072
1073  mgr.getAudioAssets(fetchOptions, async (err, fetchResult) => {
1074    if (fetchResult != undefined) {
1075      console.info('fetchFileResult success');
1076      let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1077      if (fileAsset != undefined) {
1078        console.info('fileAsset.displayName :' + fileAsset.displayName);
1079      }
1080    } else {
1081      console.error('fetchFileResult fail' + err);
1082    }
1083  });
1084}
1085```
1086
1087### getAudioAssets
1088
1089getAudioAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
1090
1091
1092Obtains audio assets. This API uses a promise to return the result.
1093
1094**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1095
1096**Required permissions**: ohos.permission.READ_AUDIO
1097
1098**Parameters**
1099
1100| Name  | Type                    | Mandatory| Description                     |
1101| -------- | ------------------------ | ---- | ------------------------- |
1102| options  | [FetchOptions](#fetchoptions)        | Yes  | Options for fetching the audio assets.             |
1103
1104**Return value**
1105
1106| Type                       | Description          |
1107| --------------------------- | -------------- |
1108| Promise&lt;[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;&gt; | Promise used to return the audio assets obtained.|
1109
1110**Error codes**
1111
1112For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1113
1114| ID| Error Message|
1115| -------- | ---------------------------------------- |
1116| 13900020   | if type options is not FetchOptions.         |
1117
1118**Example**
1119
1120```ts
1121import dataSharePredicates from '@ohos.data.dataSharePredicates';
1122
1123async function example() {
1124  console.info('getAudioAssets');
1125  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1126  let fetchOptions: userFileManager.FetchOptions = {
1127    fetchColumns: [],
1128    predicates: predicates
1129  };
1130  try {
1131    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getAudioAssets(fetchOptions);
1132    if (fetchResult != undefined) {
1133      console.info('fetchFileResult success');
1134      let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1135      if (fileAsset != undefined) {
1136        console.info('fileAsset.displayName :' + fileAsset.displayName);
1137      }
1138    }
1139  } catch (err) {
1140    console.error('getAudioAssets failed, message = ', err);
1141  }
1142}
1143```
1144
1145### delete
1146
1147delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
1148
1149Deletes a media file. This API uses an asynchronous callback to return the result. The deleted file is moved to the recycle bin.
1150
1151**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
1152
1153**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1154
1155**Parameters**
1156
1157| Name  | Type                     | Mandatory| Description      |
1158| -------- | ------------------------- | ---- | ---------- |
1159| uri | string | Yes  | URI of the media file.|
1160| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
1161
1162**Error codes**
1163
1164For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1165
1166| ID| Error Message|
1167| -------- | ---------------------------------------- |
1168| 13900020   | if type uri is not string.         |
1169
1170**Example**
1171
1172```ts
1173import dataSharePredicates from '@ohos.data.dataSharePredicates';
1174
1175async function example() {
1176  console.info('deleteAssetDemo');
1177  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1178  let fetchOptions: userFileManager.FetchOptions = {
1179    fetchColumns: [],
1180    predicates: predicates
1181  };
1182  try {
1183    const fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
1184    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1185
1186
1187    if (asset == undefined) {
1188      console.error('asset not exist');
1189      return;
1190    }
1191    mgr.delete(asset.uri, (err) => {
1192      if (err == undefined) {
1193        console.info('delete successfully');
1194      } else {
1195        console.error('delete failed with error: ' + err);
1196      }
1197    });
1198  } catch (err) {
1199    console.info('fetch failed, message =', err);
1200  }
1201}
1202```
1203
1204### delete
1205
1206delete(uri: string): Promise&lt;void&gt;;
1207
1208Deletes a media file. This API uses a promise to return the result. The deleted file is moved to the recycle bin.
1209
1210**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
1211
1212**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1213
1214**Parameters**
1215
1216| Name  | Type                     | Mandatory| Description      |
1217| -------- | ------------------------- | ---- | ---------- |
1218| uri | string | Yes  | URI of the media file.|
1219
1220**Return value**
1221
1222| Type                                   | Description             |
1223| --------------------------------------- | ----------------- |
1224| Promise&lt;void&gt;| Promise that returns no value.|
1225
1226**Error codes**
1227
1228For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1229
1230| ID| Error Message|
1231| -------- | ---------------------------------------- |
1232| 13900020   | if type uri is not string.         |
1233
1234**Example**
1235
1236```ts
1237import dataSharePredicates from '@ohos.data.dataSharePredicates';
1238
1239async function example() {
1240  console.info('deleteDemo');
1241  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1242  let fetchOptions: userFileManager.FetchOptions = {
1243    fetchColumns: [],
1244    predicates: predicates
1245  };
1246  try {
1247    const fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
1248    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1249    if (asset == undefined) {
1250      console.error('asset not exist');
1251      return;
1252    }
1253    await mgr.delete(asset.uri);
1254    console.info('delete successfully');
1255  } catch (err) {
1256    console.error('delete failed with error: ' + err);
1257  }
1258}
1259```
1260
1261### getActivePeers
1262
1263getActivePeers(callback: AsyncCallback&lt;Array&lt;PeerInfo&gt;&gt;): void;
1264
1265Obtains information about online peer devices. This API uses an asynchronous callback to return the result.
1266
1267**System capability**: SystemCapability.FileManagement.UserFileManager.DistributedCore
1268
1269**Parameters**
1270
1271| Name  | Type                             | Mandatory| Description        |
1272| -------- | --------------------------------- | ---- | ------------ |
1273| callback | AsyncCallback&lt;Array&lt;[PeerInfo](#peerinfo)&gt;&gt; | Yes  | Callback invoked to return a list of online peer devices.|
1274
1275**Example**
1276
1277```ts
1278async function example() {
1279  console.info('getActivePeersDemo');
1280  mgr.getActivePeers((err, devicesInfo) => {
1281    if (devicesInfo != undefined) {
1282      console.log('getActivePeers succeed.');
1283      for (let i = 0; i < devicesInfo.length; i++) {
1284        console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
1285      }
1286    } else {
1287      console.error('getActivePeers failed. message = ', err);
1288    }
1289  });
1290}
1291```
1292
1293### getActivePeers
1294
1295getActivePeers(): Promise&lt;Array&lt;PeerInfo&gt;&gt;;
1296
1297Obtains information about online peer devices. This API uses a promise to return the result.
1298
1299**System capability**: SystemCapability.FileManagement.UserFileManager.DistributedCore
1300
1301**Return value**
1302
1303| Type                       | Description                         |
1304| --------------------------- | ----------------------------- |
1305| Promise&lt;Array&lt;[PeerInfo](#peerinfo)&gt;&gt; | Promise used to return a list of online peer devices.|
1306
1307**Example**
1308
1309```ts
1310async function example() {
1311  console.info('getActivePeersDemo');
1312  try {
1313    let devicesInfo: Array<userFileManager.PeerInfo> = await mgr.getActivePeers();
1314    if (devicesInfo != undefined) {
1315      console.log('getActivePeers succeed.');
1316      for (let i = 0; i < devicesInfo.length; i++) {
1317        console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
1318      }
1319    } else {
1320      console.error('get distributed fail');
1321    }
1322  } catch (err) {
1323    console.error('getActivePeers failed. message = ', err);
1324  }
1325}
1326```
1327
1328### getAllPeers
1329
1330getAllPeers(callback: AsyncCallback&lt;Array&lt;PeerInfo&gt;&gt;): void;
1331
1332Obtains information about all peer devices. This API uses an asynchronous callback to return the result.
1333
1334**System capability**: SystemCapability.FileManagement.UserFileManager.DistributedCore
1335
1336**Parameters**
1337
1338| Name  | Type                             | Mandatory| Description        |
1339| -------- | --------------------------------- | ---- | ------------ |
1340| callback | AsyncCallback&lt;Array&lt;[PeerInfo](#peerinfo)&gt;&gt; | Yes  | Callback invoked to return the peer device information obtained.|
1341
1342**Example**
1343
1344```ts
1345async function example() {
1346  console.info('getAllPeersDemo');
1347  mgr.getAllPeers((err, devicesInfo) => {
1348    if (devicesInfo != undefined) {
1349      console.log('getAllPeers succeed.');
1350      for (let i = 0; i < devicesInfo.length; i++) {
1351        console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
1352      }
1353    } else {
1354      console.error('getAllPeers failed. message = ', err);
1355    }
1356  });
1357}
1358```
1359
1360### getAllPeers
1361
1362getAllPeers(): Promise&lt;Array&lt;PeerInfo&gt;&gt;;
1363
1364Obtains information about all peer devices. This API uses a promise to return the result.
1365
1366**System capability**: SystemCapability.FileManagement.UserFileManager.DistributedCore
1367
1368**Return value**
1369
1370| Type                       | Description                         |
1371| --------------------------- | ----------------------------- |
1372| Promise&lt;Array&lt;[PeerInfo](#peerinfo)&gt;&gt; | Promise used to return the information obtained.|
1373
1374**Example**
1375
1376```ts
1377async function example() {
1378  console.info('getAllPeersDemo');
1379  try {
1380    let devicesInfo: Array<userFileManager.PeerInfo> = await mgr.getAllPeers();
1381
1382    if (devicesInfo != undefined) {
1383      console.log('getAllPeers succeed.');
1384      for (let i = 0; i < devicesInfo.length; i++) {
1385        console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
1386      }
1387    } else {
1388      console.error('get distributed fail');
1389    }
1390  } catch (err) {
1391    console.error('getAllPeers failed. message = ', err);
1392  }
1393}
1394```
1395
1396### getPhotoIndex<sup>10+</sup>
1397
1398getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback&lt;number&gt;): void
1399
1400Obtains the index of an image or video in an album. This API uses an asynchronous callback to return the result.
1401
1402**System API**: This is a system API.
1403
1404**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1405
1406**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1407
1408**Parameters**
1409
1410| Name  | Type                     | Mandatory| Description      |
1411| -------- | ------------------------- | ---- | ---------- |
1412| photoUri | string | Yes  | URI of the media asset whose index is to be obtained.|
1413| 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.  |
1414| 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 conditions or sorting modes are set, the API cannot be called successfully.     |
1415| callback | AsyncCallback&lt;number&gt;| Yes  | Callback invoked to return the index obtained.|
1416
1417**Error codes**
1418
1419For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md).
1420
1421| ID| Error Message|
1422| -------- | ---------------------------------------- |
1423| 401   | if parameter is invalid.         |
1424
1425**Example**
1426
1427```ts
1428import dataSharePredicates from '@ohos.data.dataSharePredicates';
1429
1430async function example() {
1431  try {
1432    console.info('getPhotoIndexDemo');
1433    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1434    let fetchOp: userFileManager.FetchOptions = {
1435      fetchColumns: [],
1436      predicates: predicatesForGetAsset
1437    };
1438    // Obtain the uri of the album
1439    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.FAVORITE, fetchOp);
1440    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
1441    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1442    predicates.orderByAsc(userFileManager.ImageVideoKey.DATE_MODIFIED.toString());
1443    let fetchOptions: userFileManager.FetchOptions = {
1444      fetchColumns: [userFileManager.ImageVideoKey.DATE_MODIFIED.toString()],
1445      predicates: predicates
1446    };
1447    let photoFetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOptions);
1448    let expectIndex = 1;
1449    // Obtain the uri of the second file
1450    let photoAsset: userFileManager.FileAsset = await photoFetchResult.getPositionObject(expectIndex);
1451    mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => {
1452      if (err == undefined) {
1453        console.info(`getPhotoIndex successfully and index is : ${index}`);
1454      } else {
1455        console.info(`getPhotoIndex failed;`);
1456      }
1457    });
1458  } catch (error) {
1459    console.info(`getPhotoIndex failed; error: ${error}`);
1460  }
1461}
1462```
1463
1464### getPhotoIndex<sup>10+</sup>
1465
1466getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise&lt;number&gt;
1467
1468Obtains the index of an image or video in an album. This API uses a promise to return the result.
1469
1470**System API**: This is a system API.
1471
1472**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1473
1474**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1475
1476**Parameters**
1477
1478| Name  | Type                     | Mandatory| Description      |
1479| -------- | ------------------------- | ---- | ---------- |
1480| photoUri | string | Yes  | URI of the media asset whose index is to be obtained.|
1481| 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.  |
1482| 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 conditions or sorting modes are set, the API cannot be called successfully.     |
1483
1484**Return value**
1485
1486| Type                                   | Description             |
1487| --------------------------------------- | ----------------- |
1488| Promise&lt;number&gt;| Promise used to return the index obtained.|
1489
1490**Error codes**
1491
1492For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md).
1493
1494| ID| Error Message|
1495| -------- | ---------------------------------------- |
1496| 401   | if parameter is invalid.         |
1497
1498**Example**
1499
1500```ts
1501import dataSharePredicates from '@ohos.data.dataSharePredicates';
1502import { BusinessError } from '@ohos.base';
1503
1504async function example() {
1505  try {
1506    console.info('getPhotoIndexDemo');
1507    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1508    let fetchOp: userFileManager.FetchOptions = {
1509      fetchColumns: [],
1510      predicates: predicatesForGetAsset
1511    };
1512    // Obtain the uri of the album
1513    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.FAVORITE, fetchOp);
1514    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
1515    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1516    predicates.orderByAsc(userFileManager.ImageVideoKey.DATE_MODIFIED.toString());
1517    let fetchOptions: userFileManager.FetchOptions = {
1518      fetchColumns: [userFileManager.ImageVideoKey.DATE_MODIFIED.toString()],
1519      predicates: predicates
1520    };
1521    let photoFetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOptions);
1522    let expectIndex = 1;
1523    // Obtain the uri of the second file
1524    let photoAsset: userFileManager.FileAsset = await photoFetchResult.getPositionObject(expectIndex);
1525    mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions).then((index) => {
1526      console.info(`getPhotoIndex successfully and index is : ${index}`);
1527    }).catch((err: BusinessError) => {
1528      console.info(`getPhotoIndex failed; error: ${err}`);
1529    });
1530  } catch (error) {
1531    console.info(`getPhotoIndex failed; error: ${error}`);
1532  }
1533}
1534```
1535
1536### release
1537
1538release(callback: AsyncCallback&lt;void&gt;): void
1539
1540Releases this **UserFileManager** instance. This API uses an asynchronous callback to return the result.
1541Call this API when the APIs in the **UserFileManager** instance are no longer used.
1542
1543**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1544
1545**Parameters**
1546
1547| Name  | Type                     | Mandatory| Description                |
1548| -------- | ------------------------- | ---- | -------------------- |
1549| callback | AsyncCallback&lt;void&gt; | Yes  | Callback invoked to return the result.|
1550
1551**Example**
1552
1553```ts
1554async function example() {
1555  console.info('releaseDemo');
1556  mgr.release((err) => {
1557    if (err != undefined) {
1558      console.error('release failed. message = ', err);
1559    } else {
1560      console.info('release ok.');
1561    }
1562  });
1563}
1564```
1565
1566### release
1567
1568release(): Promise&lt;void&gt;
1569
1570Releases this **UserFileManager** instance. This API uses a promise to return the result.
1571Call this API when the APIs in the **UserFileManager** instance are no longer used.
1572
1573**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1574
1575**Return value**
1576
1577| Type               | Description                             |
1578| ------------------- | --------------------------------- |
1579| Promise&lt;void&gt; | Promise that returns no value.|
1580
1581**Example**
1582
1583```ts
1584async function example() {
1585  console.info('releaseDemo');
1586  try {
1587    await mgr.release();
1588    console.info('release ok.');
1589  } catch (err) {
1590    console.error('release failed. message = ', err);
1591  }
1592}
1593```
1594
1595### on<sup>10+</sup>
1596
1597on(uri: string, forSubUri: boolean, callback: Callback&lt;ChangeData&gt;) : void
1598
1599Registers a listener for the specified URI.
1600
1601**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1602
1603**Parameters**
1604
1605| Name   | Type                                       | Mandatory| Description                                                        |
1606| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
1607| uri       | string                                      | Yes  | URI of the file asset or album, or [DefaultChangeUri](#defaultchangeuri10).|
1608| forSubUri | 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. <br>If **uri** is the URI of a file asset, there is no difference between **true** and **false** for **forSubUri**.<br>If **uri** is **DefaultChangeUri**, **forSubUri** must be set to **true**. If **forSubUri** is **false**, the URI cannot be found and no message can be received.|
1609| callback  | Callback&lt;[ChangeData](#changedata10)&gt; | Yes  | Callback invoked to return [ChangeData](#changedata10). <br>**NOTE**: Different callbacks can be registered for a URI. You can use [off<sup>10+</sup>](#off10) to disable the specified callback or all callbacks for the URI.|
1610
1611**Error codes**
1612
1613For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1614
1615| ID| Error Message|
1616| -------- | ---------------------------------------- |
1617| 13900020   | if parameter is invalid.         |
1618
1619**Example**
1620
1621```ts
1622import dataSharePredicates from '@ohos.data.dataSharePredicates';
1623
1624async function example() {
1625  console.info('onDemo');
1626  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1627  let fetchOptions: userFileManager.FetchOptions = {
1628    fetchColumns: [],
1629    predicates: predicates
1630  };
1631  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
1632  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1633  if (fileAsset != undefined) {
1634    console.info('fileAsset.displayName : ' + fileAsset.displayName);
1635  }
1636  let onCallback1 = (changeData: userFileManager.ChangeData) => {
1637      console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
1638    //file had changed, do something
1639  }
1640  let onCallback2 = (changeData: userFileManager.ChangeData) => {
1641      console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
1642    // File changed. Do something.
1643  }
1644  // Register onCallback1.
1645  mgr.on(fileAsset.uri, false, onCallback1);
1646  // Register onCallback2.
1647  mgr.on(fileAsset.uri, false, onCallback2);
1648
1649  fileAsset.favorite(true, (err) => {
1650    if (err == undefined) {
1651      console.info('favorite successfully');
1652    } else {
1653      console.error('favorite failed with error:' + err);
1654    }
1655  });
1656}
1657```
1658
1659### off<sup>10+</sup>
1660
1661 off(uri: string, callback?: Callback&lt;ChangeData&gt;): void
1662
1663Unregisters the listener for the specified URI. Multiple callbacks can be registered for a URI for listening. You can use this API to unregister the specified callbacks or all callbacks.
1664
1665**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1666
1667**Parameters**
1668
1669| Name  | Type                                       | Mandatory| Description                                                        |
1670| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
1671| uri      | string                                      | Yes  | URI of the file asset or album, or [DefaultChangeUri](#defaultchangeuri10).|
1672| callback | Callback&lt;[ChangeData](#changedata10)&gt; | No  | Callback registered by [on<sup>10+</sup>](#on10). If this parameter is not specified, all listener callbacks registered for the URI will be unregistered. <br>**NOTE**: The specified callback will not be invoked.|
1673
1674**Error codes**
1675
1676For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
1677
1678| ID| Error Message|
1679| -------- | ---------------------------------------- |
1680| 13900020   | if parameter is invalid.         |
1681
1682**Example**
1683
1684```ts
1685import dataSharePredicates from '@ohos.data.dataSharePredicates';
1686
1687async function example() {
1688  console.info('offDemo');
1689  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1690  let fetchOptions: userFileManager.FetchOptions = {
1691    fetchColumns: [],
1692    predicates: predicates
1693  };
1694  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
1695  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1696  if (fileAsset != undefined) {
1697    console.info('fileAsset.displayName : ' + fileAsset.displayName);
1698  }
1699  let onCallback1 = (changeData: userFileManager.ChangeData) => {
1700    console.info('onCallback1 on');
1701  }
1702  let onCallback2 = (changeData: userFileManager.ChangeData) => {
1703    console.info('onCallback2 on');
1704  }
1705  // Register onCallback1.
1706  mgr.on(fileAsset.uri, false, onCallback1);
1707  // Register onCallback2.
1708  mgr.on(fileAsset.uri, false, onCallback2);
1709  // Disable the listening of onCallback1.
1710  mgr.off(fileAsset.uri, onCallback1);
1711  fileAsset.favorite(true, (err) => {
1712    if (err == undefined) {
1713      console.info('favorite successfully');
1714    } else {
1715      console.error('favorite failed with error:' + err);
1716    }
1717  });
1718}
1719```
1720
1721### on
1722
1723on(type: ChangeEvent, callback: Callback&lt;void&gt;): void
1724
1725Subscribes to changes of the file management library. This API uses a callback to return the result.
1726
1727This API will be deprecated. Use [on<sup>10+</sup>](#on10) instead.
1728
1729**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1730
1731**Parameters**
1732
1733| Name  | Type                | Mandatory| Description                                                        |
1734| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1735| type     | [ChangeEvent](#changeevent)               | Yes  | Type of event to subscribe to.<br>**deviceChange** indicates the device change.<br>**albumChange** indicates the album change.<br>**imageChange** indicates the image change.<br>**audioChange** indicates the audio file change.<br>**videoChange** indicates the video file change.<br>**remoteFileChange** indicates the file change on the registered device.|
1736| callback | Callback&lt;void&gt; | Yes  | Callback that returns no value.                                                  |
1737
1738**Example**
1739
1740```ts
1741async function example() {
1742  console.info('onDemo');
1743  let count = 0;
1744  mgr.on('imageChange', () => {
1745    count++;
1746    // Image file changed. Do something.
1747  });
1748  try {
1749    let testFileName: string = 'testFile' + Date.now() + '.jpg';
1750    let fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName);
1751    console.info('createPhotoAsset file displayName' + fileAsset.displayName);
1752    console.info('createPhotoAsset successfully');
1753  } catch (err) {
1754    console.error('createPhotoAsset failed, message = ' + err);
1755  }
1756  // Sleep 1s.
1757  if (count > 0) {
1758    console.info('onDemo success');
1759  } else {
1760    console.error('onDemo fail');
1761  }
1762  mgr.off('imageChange', () => {
1763    // Unsubscription succeeds.
1764  });
1765}
1766```
1767
1768### off
1769
1770off(type: ChangeEvent, callback?: Callback&lt;void&gt;): void
1771
1772Unsubscribes from changes of the file management library. This API uses a callback to return the result.
1773
1774This API will be deprecated. Use [off<sup>10+</sup>](#off10) instead.
1775
1776**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1777
1778**Parameters**
1779
1780| Name  | Type                | Mandatory| Description                                                        |
1781| -------- | -------------------- | ---- | ------------------------------------------------------------ |
1782| type     | [ChangeEvent](#changeevent)               | Yes  | Type of event to subscribe to.<br>**deviceChange** indicates the device change.<br>**albumChange** indicates the album change.<br>**imageChange** indicates the image change.<br>**audioChange** indicates the audio file change.<br>**videoChange** indicates the video file change.<br>**remoteFileChange** indicates the change of the file on a registered device.|
1783| callback | Callback&lt;void&gt; | No  | Callback that returns no value.                                                  |
1784
1785**Example**
1786
1787```ts
1788async function example() {
1789  console.info('offDemo');
1790  let count = 0;
1791  mgr.on('imageChange', () => {
1792    count++;
1793    // Image file changed. Do something.
1794  });
1795
1796  mgr.off('imageChange', () => {
1797    // Unsubscription succeeds.
1798  });
1799
1800  try {
1801    let testFileName: string = 'testFile' + Date.now() + '.jpg';
1802    let fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName);
1803    console.info('createPhotoAsset file displayName' + fileAsset.displayName);
1804    console.info('createPhotoAsset successfully');
1805  } catch (err) {
1806    console.error('createPhotoAsset failed, message = ' + err);
1807  }
1808  // Sleep 1s.
1809  if (count == 0) {
1810    console.info('offDemo success');
1811  } else {
1812    console.error('offDemo fail');
1813  }
1814}
1815```
1816
1817## FileAsset
1818
1819Provides APIs for encapsulating file asset attributes.
1820
1821### Attributes
1822
1823**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1824
1825| Name                     | Type                    | Readable| Writable| Description                                                  |
1826| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
1827| 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).        |
1828| fileType   | [FileType](#filetype) | Yes  | No  | Type of the file.                                              |
1829| displayName               | string                   | Yes  | Yes  | File name, including the file name extension, to display.                                |
1830
1831### get
1832
1833get(member: string): MemberType;
1834
1835Obtains the value of a **FileAsset** parameter.
1836
1837**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1838
1839**Parameters**
1840
1841| Name     | Type                       | Mandatory  | Description   |
1842| -------- | ------------------------- | ---- | ----- |
1843| member | string | Yes   | Member parameter name, for example, **ImageVideoKey.DISPLAY_NAME**. You need to enter the **PhotoKeys** to be obtained in **fetchColumns** for all attributes except **uri**, **photoType**, and **displayName**. For example, **fetchColumns: ['title']**.|
1844
1845**Example**
1846
1847```ts
1848import dataSharePredicates from '@ohos.data.dataSharePredicates';
1849
1850async function example() {
1851  console.info('fileAssetGetDemo');
1852  try {
1853    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1854    let fetchOption: userFileManager.FetchOptions = {
1855      fetchColumns: ['title'],
1856      predicates: predicates
1857    };
1858    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
1859    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1860    let title: userFileManager.ImageVideoKey = userFileManager.ImageVideoKey.TITLE;
1861    let fileAssetTitle: userFileManager.MemberType = fileAsset.get(title.toString());
1862    console.info('fileAsset Get fileAssetTitle = ', fileAssetTitle);
1863  } catch (err) {
1864    console.error('release failed. message = ', err);
1865  }
1866}
1867```
1868
1869### set
1870
1871set(member: string, value: string): void;
1872
1873Sets a **FileAsset** parameter.
1874
1875**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1876
1877**Parameters**
1878
1879| Name     | Type                       | Mandatory  | Description   |
1880| -------- | ------------------------- | ---- | ----- |
1881| member | string | Yes   | Member parameter name, for example, **ImageVideoKey.DISPLAY_NAME**.|
1882| value | string | Yes   | Value to set. Only the values of **DISPLAY_NAME** and **TITLE** can be changed.|
1883
1884**Example**
1885
1886```ts
1887import dataSharePredicates from '@ohos.data.dataSharePredicates';
1888
1889async function example() {
1890  console.info('fileAssetSetDemo');
1891  try {
1892    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1893    let fetchOption: userFileManager.FetchOptions = {
1894      fetchColumns: [],
1895      predicates: predicates
1896    };
1897    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
1898    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1899    let displayName: string = userFileManager.ImageVideoKey.DISPLAY_NAME.toString();
1900    fileAsset.set(displayName, 'newDisplayName1');
1901  } catch (err) {
1902    console.error('release failed. message = ', err);
1903  }
1904}
1905```
1906
1907### commitModify
1908
1909commitModify(callback: AsyncCallback&lt;void&gt;): void
1910
1911Commits the modification on the file metadata to the database. This API uses an asynchronous callback to return the result.
1912
1913**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
1914
1915**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1916
1917**Parameters**
1918
1919| Name     | Type                       | Mandatory  | Description   |
1920| -------- | ------------------------- | ---- | ----- |
1921| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
1922
1923**Example**
1924
1925```ts
1926import dataSharePredicates from '@ohos.data.dataSharePredicates';
1927
1928async function example() {
1929  console.info('commitModifyDemo');
1930  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1931  let fetchOption: userFileManager.FetchOptions = {
1932    fetchColumns: [],
1933    predicates: predicates
1934  };
1935  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
1936  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1937  let displayName: string = userFileManager.ImageVideoKey.DISPLAY_NAME.toString();
1938  let fileAssetDisplayName: userFileManager.MemberType = fileAsset.get(displayName);
1939  console.info('fileAsset get fileAssetDisplayName = ', fileAssetDisplayName);
1940  let newFileAssetDisplayName = 'new' + fileAssetDisplayName;
1941  console.info('fileAsset newFileAssetDisplayName = ', newFileAssetDisplayName);
1942  fileAsset.set(displayName, newFileAssetDisplayName);
1943  fileAsset.commitModify((err) => {
1944    if (err == undefined) {
1945      let commitModifyDisplayName = fileAsset.get(displayName);
1946      console.info('fileAsset commitModify successfully, commitModifyDisplayName = ', commitModifyDisplayName);
1947    } else {
1948      console.error('commitModify failed, message =', err);
1949    }
1950  });
1951}
1952```
1953
1954### commitModify
1955
1956commitModify(): Promise&lt;void&gt;
1957
1958Commits the modification on the file metadata to the database. This API uses a promise to return the result.
1959
1960**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
1961
1962**System capability**: SystemCapability.FileManagement.UserFileManager.Core
1963
1964**Return value**
1965
1966| Type                 | Description        |
1967| ------------------- | ---------- |
1968| Promise&lt;void&gt; | Promise that returns no value.|
1969
1970**Example**
1971
1972```ts
1973import dataSharePredicates from '@ohos.data.dataSharePredicates';
1974
1975async function example() {
1976  console.info('commitModifyDemo');
1977  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1978  let fetchOption: userFileManager.FetchOptions = {
1979    fetchColumns: [],
1980    predicates: predicates
1981  };
1982  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
1983  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
1984  let displayName = userFileManager.ImageVideoKey.DISPLAY_NAME.toString();
1985  let fileAssetDisplayName: userFileManager.MemberType = fileAsset.get(displayName);
1986  console.info('fileAsset get fileAssetDisplayName = ', fileAssetDisplayName);
1987  let newFileAssetDisplayName = 'new' + fileAssetDisplayName;
1988  console.info('fileAsset newFileAssetDisplayName = ', newFileAssetDisplayName);
1989  fileAsset.set(displayName, newFileAssetDisplayName);
1990  try {
1991    await fileAsset.commitModify();
1992    let commitModifyDisplayName = fileAsset.get(displayName);
1993    console.info('fileAsset commitModify successfully, commitModifyDisplayName = ', commitModifyDisplayName);
1994  } catch (err) {
1995    console.error('commitModify failed. message = ', err);
1996  }
1997}
1998```
1999
2000### open
2001
2002open(mode: string, callback: AsyncCallback&lt;number&gt;): void
2003
2004Opens this file asset. This API uses an asynchronous callback to return the result.
2005
2006> **NOTE**<br>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
2007
2008**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
2009
2010**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2011
2012**Parameters**
2013
2014| Name     | Type                         | Mandatory  | Description                                 |
2015| -------- | --------------------------- | ---- | ----------------------------------- |
2016| mode     | string                      | Yes   | File open mode, which can be **r** (read-only), **w** (write-only), or **rw** (read-write).|
2017| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the file descriptor (FD) of the file opened.                           |
2018
2019**Example**
2020
2021```ts
2022async function example() {
2023  console.info('openDemo');
2024   let testFileName: string = 'testFile' + Date.now() + '.jpg';
2025  const fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName);
2026  fileAsset.open('rw', (err, fd) => {
2027    if (fd != undefined) {
2028      console.info('File fd' + fd);
2029      fileAsset.close(fd);
2030    } else {
2031      console.error('File err' + err);
2032    }
2033  });
2034}
2035```
2036
2037### open
2038
2039open(mode: string): Promise&lt;number&gt;
2040
2041Opens this file asset. This API uses a promise to return the result.
2042
2043> **NOTE**<br>The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
2044
2045**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
2046
2047**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2048
2049**Parameters**
2050
2051| Name | Type    | Mandatory  | Description                                 |
2052| ---- | ------ | ---- | ----------------------------------- |
2053| mode | string | Yes   | File open mode, which can be **r** (read-only), **w** (write-only), or **rw** (read-write).|
2054
2055**Return value**
2056
2057| Type                   | Description           |
2058| --------------------- | ------------- |
2059| Promise&lt;number&gt; | Promise used to return the FD of the file opened.|
2060
2061**Example**
2062
2063```ts
2064async function example() {
2065  console.info('openDemo');
2066  try {
2067    let testFileName: string = 'testFile' + Date.now() + '.jpg';
2068    const fileAsset: userFileManager.FileAsset = await mgr.createPhotoAsset(testFileName);
2069    let fd: number = await fileAsset.open('rw');
2070    if (fd != undefined) {
2071      console.info('File fd' + fd);
2072      fileAsset.close(fd);
2073    } else {
2074      console.error(' open File fail');
2075    }
2076  } catch (err) {
2077    console.error('open Demo err' + err);
2078  }
2079}
2080```
2081
2082### close
2083
2084close(fd: number, callback: AsyncCallback&lt;void&gt;): void
2085
2086Closes a file asset. This API uses an asynchronous callback to return the result.
2087
2088**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2089
2090**Parameters**
2091
2092| Name     | Type                       | Mandatory  | Description   |
2093| -------- | ------------------------- | ---- | ----- |
2094| fd       | number                    | Yes   | FD of the file to close.|
2095| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
2096
2097**Example**
2098
2099```ts
2100import dataSharePredicates from '@ohos.data.dataSharePredicates';
2101
2102async function example() {
2103  console.info('closeDemo');
2104  try {
2105    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2106    let fetchOption: userFileManager.FetchOptions = {
2107      fetchColumns: [],
2108      predicates: predicates
2109    };
2110    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2111    const fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2112    let fd: number = await fileAsset.open('rw');
2113    console.info('file fd', fd);
2114    fileAsset.close(fd, (err) => {
2115      if (err == undefined) {
2116        console.info('asset close succeed.');
2117      } else {
2118        console.error('close failed, message = ' + err);
2119      }
2120    });
2121  } catch (err) {
2122    console.error('close failed, message = ' + err);
2123  }
2124}
2125```
2126
2127### close
2128
2129close(fd: number): Promise&lt;void&gt;
2130
2131Closes a file asset. This API uses a promise to return the result.
2132
2133**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2134
2135**Parameters**
2136
2137| Name | Type    | Mandatory  | Description   |
2138| ---- | ------ | ---- | ----- |
2139| fd   | number | Yes   | FD of the file to close.|
2140
2141**Return value**
2142
2143| Type                 | Description        |
2144| ------------------- | ---------- |
2145| Promise&lt;void&gt; | Promise that returns no value.|
2146
2147**Example**
2148
2149```ts
2150import dataSharePredicates from '@ohos.data.dataSharePredicates';
2151
2152async function example() {
2153  console.info('closeDemo');
2154  try {
2155    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2156    let fetchOption: userFileManager.FetchOptions = {
2157      fetchColumns: [],
2158      predicates: predicates
2159    };
2160    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2161    const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2162    let fd: number = await asset.open('rw');
2163    console.info('file fd', fd);
2164    await asset.close(fd);
2165    console.info('asset close succeed.');
2166  } catch (err) {
2167    console.error('close failed, message = ' + err);
2168  }
2169}
2170```
2171
2172### getThumbnail
2173
2174getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
2175
2176Obtains the thumbnail of this file asset. This API uses an asynchronous callback to return the result.
2177
2178**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
2179
2180**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2181
2182**Parameters**
2183
2184| Name     | Type                                 | Mandatory  | Description              |
2185| -------- | ----------------------------------- | ---- | ---------------- |
2186| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked to return the PixelMap of the thumbnail.|
2187
2188**Example**
2189
2190```ts
2191import dataSharePredicates from '@ohos.data.dataSharePredicates';
2192
2193async function example() {
2194  console.info('getThumbnailDemo');
2195  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2196  let fetchOption: userFileManager.FetchOptions = {
2197    fetchColumns: [],
2198    predicates: predicates
2199  };
2200  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2201  let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2202  console.info('asset displayName = ', asset.displayName);
2203  asset.getThumbnail((err, pixelMap) => {
2204    if (err == undefined) {
2205      console.info('getThumbnail successful ' + pixelMap);
2206    } else {
2207      console.error('getThumbnail fail', err);
2208    }
2209  });
2210}
2211```
2212
2213### getThumbnail
2214
2215getThumbnail(size: image.Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
2216
2217Obtains the file thumbnail of the given size. This API uses an asynchronous callback to return the result.
2218
2219**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
2220
2221**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2222
2223**Parameters**
2224
2225| Name     | Type                                 | Mandatory  | Description              |
2226| -------- | ----------------------------------- | ---- | ---------------- |
2227| size     | [image.Size](js-apis-image.md#size) | Yes   | Size of the thumbnail.           |
2228| callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes   | Callback invoked to return the PixelMap of the thumbnail.|
2229
2230**Example**
2231
2232```ts
2233import dataSharePredicates from '@ohos.data.dataSharePredicates';
2234import image from '@ohos.multimedia.image';
2235
2236async function example() {
2237  console.info('getThumbnailDemo');
2238  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2239  let fetchOption: userFileManager.FetchOptions = {
2240    fetchColumns: [],
2241    predicates: predicates
2242  };
2243  let size: image.Size = { width: 720, height: 720 };
2244  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2245  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2246  console.info('asset displayName = ', asset.displayName);
2247  asset.getThumbnail(size, (err, pixelMap) => {
2248    if (err == undefined) {
2249      console.info('getThumbnail successful ' + pixelMap);
2250    } else {
2251      console.error('getThumbnail fail', err);
2252    }
2253  });
2254}
2255```
2256
2257### getThumbnail
2258
2259getThumbnail(size?: image.Size): Promise&lt;image.PixelMap&gt;
2260
2261Obtains the file thumbnail of the given size. This API uses a promise to return the result.
2262
2263**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
2264
2265**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2266
2267**Parameters**
2268
2269| Name | Type            | Mandatory  | Description   |
2270| ---- | -------------- | ---- | ----- |
2271| size | [image.Size](js-apis-image.md#size) | No   | Size of the thumbnail.|
2272
2273**Return value**
2274
2275| Type                           | Description                   |
2276| ----------------------------- | --------------------- |
2277| Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise used to return the PixelMap of the thumbnail.|
2278
2279**Example**
2280
2281```ts
2282import dataSharePredicates from '@ohos.data.dataSharePredicates';
2283import image from '@ohos.multimedia.image';
2284import { BusinessError } from '@ohos.base';
2285
2286async function example() {
2287  console.info('getThumbnailDemo');
2288  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2289  let fetchOption: userFileManager.FetchOptions = {
2290    fetchColumns: [],
2291    predicates: predicates
2292  };
2293  let size: image.Size = { width: 720, height: 720 };
2294  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2295  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2296  console.info('asset displayName = ', asset.displayName);
2297  asset.getThumbnail(size).then((pixelMap) => {
2298    console.info('getThumbnail successful ' + pixelMap);
2299  }).catch((err: BusinessError) => {
2300    console.error('getThumbnail fail' + err);
2301  });
2302}
2303```
2304
2305### favorite
2306
2307favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void
2308
2309Favorites or unfavorites this file asset. This API uses an asynchronous callback to return the result.
2310
2311**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
2312
2313**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2314
2315**Parameters**
2316
2317| Name       | Type                       | Mandatory  | Description                                |
2318| ---------- | ------------------------- | ---- | ---------------------------------- |
2319| isFavorite | boolean                   | Yes   | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
2320| callback   | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.                             |
2321
2322**Example**
2323
2324```ts
2325import dataSharePredicates from '@ohos.data.dataSharePredicates';
2326
2327async function example() {
2328  console.info('favoriteDemo');
2329  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2330  let fetchOption: userFileManager.FetchOptions = {
2331    fetchColumns: [],
2332    predicates: predicates
2333  };
2334  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2335  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2336  asset.favorite(true, (err) => {
2337    if (err == undefined) {
2338      console.info('favorite successfully');
2339    } else {
2340      console.error('favorite failed with error:' + err);
2341    }
2342  });
2343}
2344```
2345
2346### favorite
2347
2348favorite(isFavorite: boolean): Promise&lt;void&gt;
2349
2350Favorites or unfavorites this file asset. This API uses a promise to return the result.
2351
2352**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
2353
2354**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2355
2356**Parameters**
2357
2358| Name       | Type     | Mandatory  | Description                                |
2359| ---------- | ------- | ---- | ---------------------------------- |
2360| isFavorite | boolean | Yes   | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
2361
2362**Return value**
2363
2364| Type                 | Description        |
2365| ------------------- | ---------- |
2366| Promise&lt;void&gt; | Promise that returns no value.|
2367
2368**Example**
2369
2370```ts
2371import dataSharePredicates from '@ohos.data.dataSharePredicates';
2372import { BusinessError } from '@ohos.base';
2373
2374async function example() {
2375  console.info('favoriteDemo');
2376  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2377  let fetchOption: userFileManager.FetchOptions = {
2378    fetchColumns: [],
2379    predicates: predicates
2380  };
2381  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2382  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2383  asset.favorite(true).then(() => {
2384    console.info('favorite successfully');
2385  }).catch((err: BusinessError) => {
2386    console.error('favorite failed with error:' + err);
2387  });
2388}
2389```
2390
2391### setHidden<sup>10+</sup>
2392
2393setHidden(hiddenState: boolean, callback: AsyncCallback&lt;void&gt;): void
2394
2395Sets this file asset to hidden state. This API uses an asynchronous callback to return the result.
2396
2397The private files set to hidden state are located in the private album (in hidden state) and are not open to third-party applications. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album.
2398
2399**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2400
2401**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2402
2403**Parameters**
2404
2405| Name       | Type                       | Mandatory  | Description                                |
2406| ---------- | ------------------------- | ---- | ---------------------------------- |
2407| 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.|
2408| callback   | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.                             |
2409
2410**Error codes**
2411
2412For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md) and [Universal Error Codes](../errorcodes/errorcode-universal.md).
2413
2414| ID| Error Message|
2415| -------- | ---------------------------------------- |
2416| 202   | Called by non-system application.                |
2417| 13900020   | if parameter is invalid.         |
2418
2419**Example**
2420
2421```ts
2422import dataSharePredicates from '@ohos.data.dataSharePredicates';
2423
2424async function example() {
2425  console.info('setHiddenDemo');
2426  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2427  let fetchOption: userFileManager.FetchOptions = {
2428    fetchColumns: [],
2429    predicates: predicates
2430  };
2431  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2432  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2433  asset.setHidden(true, (err) => {
2434    if (err == undefined) {
2435      console.info('setHidden successfully');
2436    } else {
2437      console.error('setHidden failed with error:' + err);
2438    }
2439  });
2440}
2441```
2442
2443### setHidden<sup>10+</sup>
2444
2445setHidden(hiddenState: boolean): Promise&lt;void&gt;
2446
2447Sets this file asset to hidden state. This API uses a promise to return the result.
2448
2449The private files set to hidden state are located in the private album (in hidden state) and are not open to third-party applications. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album.
2450
2451**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2452
2453**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2454
2455**Parameters**
2456
2457| Name       | Type     | Mandatory  | Description                                |
2458| ---------- | ------- | ---- | ---------------------------------- |
2459| 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.|
2460
2461**Return value**
2462
2463| Type                 | Description        |
2464| ------------------- | ---------- |
2465| Promise&lt;void&gt; | Promise that returns no value.|
2466
2467**Error codes**
2468
2469For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md) and [Universal Error Codes](../errorcodes/errorcode-universal.md).
2470
2471| ID| Error Message|
2472| -------- | ---------------------------------------- |
2473| 202   | Called by non-system application.                |
2474| 13900020   | if parameter is invalid.         |
2475
2476**Example**
2477
2478```ts
2479import dataSharePredicates from '@ohos.data.dataSharePredicates';
2480import { BusinessError } from '@ohos.base';
2481
2482async function example() {
2483  // Restore a file from a hidden album. Before the operation, ensure that the file exists in the hidden album.
2484  console.info('setHiddenDemo');
2485  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2486  let fetchOption: userFileManager.FetchOptions = {
2487    fetchColumns: [],
2488    predicates: predicates
2489  };
2490  let albumList: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.HIDDEN);
2491  const album: userFileManager.Album = await albumList.getFirstObject();
2492  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
2493  const asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2494  asset.setHidden(false).then(() => {
2495    console.info('setHidden successfully');
2496  }).catch((err: BusinessError) => {
2497    console.error('setHidden failed with error:' + err);
2498  });
2499}
2500```
2501
2502### getExif<sup>10+</sup>
2503
2504getExif(): Promise&lt;string&gt;
2505
2506Obtains a JSON string consisting of the exchangeable image file format (EXIF) tags of this JPG image. This API uses a promise to return the result.
2507
2508> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [ImageVideoKey.USER_COMMENT](#imagevideokey). These two fields must be passed in via **fetchColumns**.
2509
2510**System API**: This is a system API.
2511
2512**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2513
2514**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2515
2516**Return value**
2517
2518| Type                                   | Description             |
2519| --------------------------------------- | ----------------- |
2520| Promise&lt;string&gt; | Promise used to return the JSON string obtained.|
2521
2522**Supported EXIF tags**
2523
2524For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7).
2525
2526| Key Value                                   | Description             |
2527| --------------------------------------- | ----------------- |
2528| BitsPerSample | Number of bits per pixel.|
2529| Orientation | Image orientation.|
2530| ImageLength | Image length.|
2531| ImageWidth | Image width.|
2532| GPSLatitude | GPS latitude of the image.|
2533| GPSLongitude | GPS longitude of the image.|
2534| GPSLatitudeRef | Longitude reference, for example, W or E.|
2535| GPSLongitudeRef | Latitude reference, for example, N or S.|
2536| DateTimeOriginal | Shooting time.|
2537| ExposureTime | Exposure time.|
2538| SceneType | Shooting scene type.|
2539| ISOSpeedRatings | ISO sensitivity or speed.|
2540| FNumber | f-number.|
2541| DateTime | Date and time when the image was last modified.|
2542| GPSTimeStamp | GPS timestamp.|
2543| GPSDateStamp | GPS date stamp.|
2544| ImageDescription | Image description.|
2545| Make | Camera vendor.|
2546| Model | Model.|
2547| PhotoMode | Photo mode.|
2548| SensitivityType | Sensitivity type.|
2549| StandardOutputSensitivity | Standard output sensitivity.|
2550| RecommendedExposureIndex | Recommended exposure index.|
2551| ApertureValue | Aperture value.|
2552| MeteringMode | Metering mode.|
2553| LightSource | Light source.|
2554| Flash | Flash status.|
2555| FocalLength | Focal length.|
2556| UserComment | User comment.|
2557| PixelXDimension | Pixel X dimension.|
2558| PixelYDimension | Pixel Y dimension.|
2559| WhiteBalance | White balance.|
2560| FocalLengthIn35mmFilm | Focal length in 35 mm film.|
2561| ExposureBiasValue | Exposure compensation.|
2562
2563**Example**
2564
2565```ts
2566import dataSharePredicates from '@ohos.data.dataSharePredicates';
2567
2568async function example() {
2569  try {
2570    console.info('getExifDemo');
2571    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2572    predicates.isNotNull('all_exif')
2573    let fetchOptions: userFileManager.FetchOptions = {
2574      fetchColumns: ['all_exif', userFileManager.ImageVideoKey.USER_COMMENT.toString()],
2575      predicates: predicates
2576    };
2577    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
2578    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2579    console.info('getExifDemo fileAsset displayName: ' + JSON.stringify(fileAsset.displayName));
2580    let exifMessage: string = await fileAsset.getExif();
2581    let userCommentKey: string = 'UserComment';
2582    let userComment: string = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
2583    console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
2584    fetchResult.close();
2585  } catch (err) {
2586    console.error('getExifDemoCallback failed with error: ' + err);
2587  }
2588}
2589```
2590
2591### getExif<sup>10+</sup>
2592
2593getExif(callback: AsyncCallback&lt;string&gt;): void
2594
2595Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses an asynchronous callback to return the result.
2596
2597> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [ImageVideoKey.USER_COMMENT](#imagevideokey). These two fields must be passed in via **fetchColumns**.
2598
2599**System API**: This is a system API.
2600
2601**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2602
2603**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2604
2605**Parameters**
2606
2607| Name  | Type                     | Mandatory| Description      |
2608| -------- | ------------------------- | ---- | ---------- |
2609| callback | AsyncCallback&lt;string&gt; | Yes  | Callback invoked to return the JSON string obtained.|
2610
2611**Supported EXIF tags**
2612
2613For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7).
2614
2615| Key Value                                   | Description             |
2616| --------------------------------------- | ----------------- |
2617| BitsPerSample | Number of bits per pixel.|
2618| Orientation | Image orientation.|
2619| ImageLength | Image length.|
2620| ImageWidth | Image width.|
2621| GPSLatitude | GPS latitude of the image.|
2622| GPSLongitude | GPS longitude of the image.|
2623| GPSLatitudeRef | Longitude reference, for example, W or E.|
2624| GPSLongitudeRef | Latitude reference, for example, N or S.|
2625| DateTimeOriginal | Shooting time.|
2626| ExposureTime | Exposure time.|
2627| SceneType | Shooting scene type.|
2628| ISOSpeedRatings | ISO sensitivity or speed.|
2629| FNumber | f-number.|
2630| DateTime | Date and time when the image was last modified.|
2631| GPSTimeStamp | GPS timestamp.|
2632| GPSDateStamp | GPS date stamp.|
2633| ImageDescription | Image description.|
2634| Make | Camera vendor.|
2635| Model | Model.|
2636| PhotoMode | Photo mode.|
2637| SensitivityType | Sensitivity type.|
2638| StandardOutputSensitivity | Standard output sensitivity.|
2639| RecommendedExposureIndex | Recommended exposure index.|
2640| ApertureValue | Aperture value.|
2641| MeteringMode | Metering mode.|
2642| LightSource | Light source.|
2643| Flash | Flash status.|
2644| FocalLength | Focal length.|
2645| UserComment | User comment.|
2646| PixelXDimension | Pixel X dimension.|
2647| PixelYDimension | Pixel Y dimension.|
2648| WhiteBalance | White balance.|
2649| FocalLengthIn35mmFilm | Focal length in 35 mm film.|
2650| ExposureBiasValue | Exposure compensation.|
2651
2652**Example**
2653
2654```ts
2655import dataSharePredicates from '@ohos.data.dataSharePredicates';
2656
2657async function example() {
2658  try {
2659    console.info('getExifDemo');
2660    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2661    predicates.isNotNull('all_exif')
2662    let fetchOptions: userFileManager.FetchOptions = {
2663      fetchColumns: ['all_exif', userFileManager.ImageVideoKey.USER_COMMENT.toString()],
2664      predicates: predicates
2665    };
2666    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
2667    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2668    console.info('getExifDemo fileAsset displayName: ' + JSON.stringify(fileAsset.displayName));
2669    let userCommentKey: string = 'UserComment';
2670    fileAsset.getExif((err, exifMessage) => {
2671      if (exifMessage != undefined) {
2672        let userComment: string = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
2673        console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
2674      } else {
2675        console.error('getExif failed, message = ', err);
2676      }
2677    });
2678    fetchResult.close();
2679  } catch (err) {
2680    console.error('getExifDemoCallback failed with error: ' + err);
2681  }
2682}
2683```
2684
2685### setUserComment<sup>10+</sup>
2686
2687setUserComment(userComment: string): Promise&lt;void&gt;
2688
2689Sets user comment information of an image or video. This API uses a promise to return the result.
2690
2691> **NOTE**<br>This API can be used to modify the comment information of only images or videos.
2692
2693**System API**: This is a system API.
2694
2695**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2696
2697**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2698
2699**Parameters**
2700
2701| Name  | Type                     | Mandatory| Description      |
2702| -------- | ------------------------- | ---- | ---------- |
2703| userComment | string | Yes  | User comment information to set, which cannot exceed 140 characters.|
2704
2705**Return value**
2706
2707| Type                                   | Description             |
2708| --------------------------------------- | ----------------- |
2709|Promise&lt;void&gt; | Promise that returns no value.|
2710
2711**Example**
2712
2713```ts
2714import dataSharePredicates from '@ohos.data.dataSharePredicates';
2715
2716async function example() {
2717  try {
2718    console.info('setUserCommentDemo')
2719    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2720    let fetchOptions: userFileManager.FetchOptions = {
2721      fetchColumns: [],
2722      predicates: predicates
2723    };
2724    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
2725    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2726    let userComment: string = 'test_set_user_comment';
2727    await fileAsset.setUserComment(userComment);
2728  } catch (err) {
2729    console.error('setUserCommentDemoCallback failed with error: ' + err);
2730  }
2731}
2732```
2733
2734### setUserComment<sup>10+</sup>
2735
2736setUserComment(userComment: string, callback: AsyncCallback&lt;void&gt;): void
2737
2738Sets user comment information of an image or video. This API uses an asynchronous callback to return the result.
2739
2740> **NOTE**<br>This API can be used to modify the comment information of only images or videos.
2741
2742**System API**: This is a system API.
2743
2744**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2745
2746**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2747
2748**Parameters**
2749
2750| Name  | Type                     | Mandatory| Description      |
2751| -------- | ------------------------- | ---- | ---------- |
2752| userComment | string | Yes  | User comment information to set, which cannot exceed 140 characters.|
2753| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2754
2755**Example**
2756
2757```ts
2758import dataSharePredicates from '@ohos.data.dataSharePredicates';
2759
2760async function example() {
2761  try {
2762    console.info('setUserCommentDemo')
2763    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2764    let fetchOptions: userFileManager.FetchOptions = {
2765      fetchColumns: [],
2766      predicates: predicates
2767    };
2768    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOptions);
2769    let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2770    let userComment: string = 'test_set_user_comment';
2771    fileAsset.setUserComment(userComment, (err) => {
2772      if (err === undefined) {
2773        console.info('setUserComment successfully');
2774      } else {
2775        console.error('setUserComment failed with error: ' + err);
2776      }
2777    });
2778  } catch (err) {
2779    console.error('setUserCommentDemoCallback failed with error: ' + err);
2780  }
2781}
2782```
2783
2784## FetchResult
2785
2786Provides APIs to manage the file retrieval result.
2787
2788### getCount
2789
2790getCount(): number
2791
2792Obtains the total number of files in the result set.
2793
2794**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2795
2796**Return value**
2797
2798| Type    | Description      |
2799| ------ | -------- |
2800| number | Returns the total number of files obtained.|
2801
2802**Example**
2803
2804```ts
2805import dataSharePredicates from '@ohos.data.dataSharePredicates';
2806
2807async function example() {
2808  console.info('getCountDemo');
2809  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2810  let fetchOption: userFileManager.FetchOptions = {
2811    fetchColumns: [],
2812    predicates: predicates
2813  };
2814  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2815  const fetchCount: number = fetchResult.getCount();
2816  console.info('fetchCount = ', fetchCount);
2817}
2818```
2819
2820### isAfterLast
2821
2822isAfterLast(): boolean
2823
2824Checks whether the cursor is in the last row of the result set.
2825
2826**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2827
2828**Return value**
2829
2830| Type     | Description                                |
2831| ------- | ---------------------------------- |
2832| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.|
2833
2834**Example**
2835
2836```ts
2837import dataSharePredicates from '@ohos.data.dataSharePredicates';
2838
2839async function example() {
2840  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2841  let fetchOption: userFileManager.FetchOptions = {
2842    fetchColumns: [],
2843    predicates: predicates
2844  };
2845  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2846  const fetchCount: number = fetchResult.getCount();
2847  console.info('count:' + fetchCount);
2848  let fileAsset: userFileManager.FileAsset = await fetchResult.getLastObject();
2849  if (fetchResult.isAfterLast()) {
2850    console.info('fileAsset isAfterLast displayName = ', fileAsset.displayName);
2851  } else {
2852    console.info('fileAsset  not isAfterLast ');
2853  }
2854}
2855```
2856
2857### close
2858
2859close(): void
2860
2861Releases and invalidates this **FetchFileResult** instance. After this instance is released, the APIs in this instance cannot be invoked.
2862
2863**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2864
2865**Example**
2866
2867```ts
2868import dataSharePredicates from '@ohos.data.dataSharePredicates';
2869
2870async function example() {
2871  console.info('fetchResultCloseDemo');
2872  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2873  let fetchOption: userFileManager.FetchOptions = {
2874    fetchColumns: [],
2875    predicates: predicates
2876  };
2877  try {
2878    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2879    fetchResult.close();
2880    console.info('close succeed.');
2881  } catch (err) {
2882    console.error('close fail. message = ' + err);
2883  }
2884}
2885```
2886
2887### getFirstObject
2888
2889getFirstObject(callback: AsyncCallback&lt;T&gt;): void
2890
2891Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result.
2892
2893**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2894
2895**Parameters**
2896
2897| Name  | Type                                         | Mandatory| Description                                       |
2898| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
2899| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the first file asset.|
2900
2901**Example**
2902
2903```ts
2904import dataSharePredicates from '@ohos.data.dataSharePredicates';
2905
2906async function example() {
2907  console.info('getFirstObjectDemo');
2908  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2909  let fetchOption: userFileManager.FetchOptions = {
2910    fetchColumns: [],
2911    predicates: predicates
2912  };
2913  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2914  fetchResult.getFirstObject((err, fileAsset) => {
2915    if (fileAsset != undefined) {
2916      console.info('fileAsset displayName: ', fileAsset.displayName);
2917    } else {
2918      console.error('fileAsset failed with err:' + err);
2919    }
2920  });
2921}
2922```
2923
2924### getFirstObject
2925
2926getFirstObject(): Promise&lt;T&gt;
2927
2928Obtains the first file asset in the result set. This API uses a promise to return the result.
2929
2930**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2931
2932**Return value**
2933
2934| Type                                   | Description                      |
2935| --------------------------------------- | -------------------------- |
2936| Promise&lt;T&gt; | Promise used to return the first object in the result set.|
2937
2938**Example**
2939
2940```ts
2941import dataSharePredicates from '@ohos.data.dataSharePredicates';
2942
2943async function example() {
2944  console.info('getFirstObjectDemo');
2945  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2946  let fetchOption: userFileManager.FetchOptions = {
2947    fetchColumns: [],
2948    predicates: predicates
2949  };
2950  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2951  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
2952  console.info('fileAsset displayName: ', fileAsset.displayName);
2953}
2954```
2955
2956### getNextObject
2957
2958getNextObject(callback: AsyncCallback&lt;T&gt;): void
2959
2960Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
2961Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
2962
2963**System capability**: SystemCapability.FileManagement.UserFileManager.Core
2964
2965**Parameters**
2966
2967| Name   | Type                                         | Mandatory| Description                                     |
2968| --------- | --------------------------------------------- | ---- | ----------------------------------------- |
2969| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the next file asset.|
2970
2971**Example**
2972
2973```ts
2974import dataSharePredicates from '@ohos.data.dataSharePredicates';
2975
2976async function example() {
2977  console.info('getNextObjectDemo');
2978  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2979  let fetchOption: userFileManager.FetchOptions = {
2980    fetchColumns: [],
2981    predicates: predicates
2982  };
2983  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
2984  await fetchResult.getFirstObject();
2985  if (!fetchResult.isAfterLast()) {
2986    fetchResult.getNextObject((err, fileAsset) => {
2987      if (fileAsset != undefined) {
2988        console.info('fileAsset displayName: ', fileAsset.displayName);
2989      } else {
2990        console.error('fileAsset failed with err: ' + err);
2991      }
2992    });
2993  }
2994}
2995```
2996
2997### getNextObject
2998
2999getNextObject(): Promise&lt;T&gt;
3000
3001Obtains the next file asset in the result set. This API uses a promise to return the result.
3002Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
3003
3004**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3005
3006**Return value**
3007
3008| Type                                   | Description             |
3009| --------------------------------------- | ----------------- |
3010| Promise&lt;T&gt; | Promise used to return the next object in the result set.|
3011
3012**Example**
3013
3014```ts
3015import dataSharePredicates from '@ohos.data.dataSharePredicates';
3016
3017async function example() {
3018  console.info('getNextObjectDemo');
3019  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3020  let fetchOption: userFileManager.FetchOptions = {
3021    fetchColumns: [],
3022    predicates: predicates
3023  };
3024  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3025  await fetchResult.getFirstObject();
3026  if (!fetchResult.isAfterLast()) {
3027    let fileAsset: userFileManager.FileAsset = await fetchResult.getNextObject();
3028    console.info('fileAsset displayName: ', fileAsset.displayName);
3029  }
3030}
3031```
3032
3033### getLastObject
3034
3035getLastObject(callback: AsyncCallback&lt;T&gt;): void
3036
3037Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result.
3038
3039**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3040
3041**Parameters**
3042
3043| Name  | Type                                         | Mandatory| Description                       |
3044| -------- | --------------------------------------------- | ---- | --------------------------- |
3045| callback | AsyncCallback&lt;T&gt; | Yes  | Callback invoked to return the last file asset obtained.|
3046
3047**Example**
3048
3049```ts
3050import dataSharePredicates from '@ohos.data.dataSharePredicates';
3051
3052async function example() {
3053  console.info('getLastObjectDemo');
3054  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3055  let fetchOption: userFileManager.FetchOptions = {
3056    fetchColumns: [],
3057    predicates: predicates
3058  };
3059  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3060  fetchResult.getLastObject((err, fileAsset) => {
3061    if (fileAsset != undefined) {
3062      console.info('fileAsset displayName: ', fileAsset.displayName);
3063    } else {
3064      console.error('fileAsset failed with err: ' + err);
3065    }
3066  });
3067}
3068```
3069
3070### getLastObject
3071
3072getLastObject(): Promise&lt;T&gt;
3073
3074Obtains the last file asset in the result set. This API uses a promise to return the result.
3075
3076**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3077
3078**Return value**
3079
3080| Type                                   | Description             |
3081| --------------------------------------- | ----------------- |
3082| Promise&lt;T&gt; | Promise used to return the last object in the result set.|
3083
3084**Example**
3085
3086```ts
3087import dataSharePredicates from '@ohos.data.dataSharePredicates';
3088
3089async function example() {
3090  console.info('getLastObjectDemo');
3091  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3092  let fetchOption: userFileManager.FetchOptions = {
3093    fetchColumns: [],
3094    predicates: predicates
3095  };
3096  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3097  let fileAsset: userFileManager.FileAsset = await fetchResult.getLastObject();
3098  console.info('fileAsset displayName: ', fileAsset.displayName);
3099}
3100```
3101
3102### getPositionObject
3103
3104getPositionObject(index: number, callback: AsyncCallback&lt;T&gt;): void
3105
3106Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result.
3107
3108**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3109
3110**Parameters**
3111
3112| Name      | Type                                      | Mandatory  | Description                |
3113| -------- | ---------------------------------------- | ---- | ------------------ |
3114| index    | number                                   | Yes   | Index of the file asset to obtain. The value starts from **0**.    |
3115| callback | AsyncCallback&lt;T&gt; | Yes   | Callback invoked to return the file asset obtained.|
3116
3117**Error codes**
3118
3119For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3120
3121| ID| Error Message|
3122| -------- | ---------------------------------------- |
3123| 13900020   | if type index is not number.         |
3124
3125**Example**
3126
3127```ts
3128import dataSharePredicates from '@ohos.data.dataSharePredicates';
3129
3130async function example() {
3131  console.info('getPositionObjectDemo');
3132  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3133  let fetchOption: userFileManager.FetchOptions = {
3134    fetchColumns: [],
3135    predicates: predicates
3136  };
3137  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3138  fetchResult.getPositionObject(0, (err, fileAsset) => {
3139    if (fileAsset != undefined) {
3140      console.info('fileAsset displayName: ', fileAsset.displayName);
3141    } else {
3142      console.error('fileAsset failed with err: ' + err);
3143    }
3144  });
3145}
3146```
3147
3148### getPositionObject
3149
3150getPositionObject(index: number): Promise&lt;T&gt;
3151
3152Obtains a file asset with the specified index in the result set. This API uses a promise to return the result.
3153
3154**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3155
3156**Parameters**
3157
3158| Name   | Type    | Mandatory  | Description            |
3159| ----- | ------ | ---- | -------------- |
3160| index | number | Yes   | Index of the file asset to obtain. The value starts from **0**.|
3161
3162**Return value**
3163
3164| Type                                   | Description             |
3165| --------------------------------------- | ----------------- |
3166| Promise&lt;T&gt; | Promise used to return the file asset obtained.|
3167
3168**Error codes**
3169
3170For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3171
3172| ID| Error Message|
3173| -------- | ---------------------------------------- |
3174| 13900020   | if type index is not number.         |
3175
3176**Example**
3177
3178```ts
3179import dataSharePredicates from '@ohos.data.dataSharePredicates';
3180
3181async function example() {
3182  console.info('getPositionObjectDemo');
3183  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3184  let fetchOption: userFileManager.FetchOptions = {
3185    fetchColumns: [],
3186    predicates: predicates
3187  };
3188  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3189  let fileAsset: userFileManager.FileAsset = await fetchResult.getPositionObject(0);
3190  console.info('fileAsset displayName: ', fileAsset.displayName);
3191}
3192```
3193
3194### getAllObject<sup>10+</sup>
3195
3196getAllObject(callback: AsyncCallback&lt;Array&lt;T&gt;&gt;): void
3197
3198Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result.
3199
3200**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3201
3202**Parameters**
3203
3204| Name  | Type                                         | Mandatory| Description                                       |
3205| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
3206| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | Yes  | Callback invoked to return an array of all file assets in the result set.|
3207
3208**Example**
3209
3210```ts
3211import dataSharePredicates from '@ohos.data.dataSharePredicates';
3212
3213async function example() {
3214  console.info('getAllObjectDemo');
3215  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3216  let fetchOption: userFileManager.FetchOptions = {
3217    fetchColumns: [],
3218    predicates: predicates
3219  };
3220  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3221  fetchResult.getAllObject((err, fileAssetList) => {
3222    if (fileAssetList != undefined) {
3223      console.info('fileAssetList length: ', fileAssetList.length);
3224    } else {
3225      console.error('fileAssetList failed with err:' + err);
3226    }
3227  });
3228}
3229```
3230
3231### getAllObject<sup>10+</sup>
3232
3233getAllObject(): Promise&lt;Array&lt;T&gt;&gt;
3234
3235Obtains all the file assets in the result set. This API uses a promise to return the result.
3236
3237**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3238
3239**Return value**
3240
3241| Type                                   | Description                      |
3242| --------------------------------------- | -------------------------- |
3243| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return an array of all file assets in the result set.|
3244
3245**Example**
3246
3247```ts
3248import dataSharePredicates from '@ohos.data.dataSharePredicates';
3249
3250async function example() {
3251  console.info('getAllObjectDemo');
3252  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3253  let fetchOption: userFileManager.FetchOptions = {
3254    fetchColumns: [],
3255    predicates: predicates
3256  };
3257  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3258  let fileAssetList: Array<userFileManager.FileAsset> = await fetchResult.getAllObject();
3259  console.info('fileAssetList length: ', fileAssetList.length);
3260}
3261```
3262
3263## Album
3264
3265Provides APIs to manage albums.
3266
3267### Attributes
3268
3269**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3270
3271| Name          | Type   | Readable  | Writable | Description  |
3272| ------------ | ------ | ---- | ---- | ------- |
3273| albumType<sup>10+</sup> | [AlbumType]( #albumtype10) | Yes   | No   | Type of the album.   |
3274| albumSubType<sup>10+</sup> | [AlbumSubType]( #albumsubtype10) | Yes   | No  | Subtype of the album.   |
3275| albumName | string | Yes   | Yes for a user album; no for a system album.  | Name of the album.   |
3276| albumUri | string | Yes   | No   | URI of the album.  |
3277| count | number | Yes   | No   |  Number of files in the album.|
3278| coverUri | string | Yes   | Yes for a user album; no for a system album.    | URI of the cover file of the album.|
3279
3280### getPhotoAssets
3281
3282getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
3283
3284Obtains image and video assets. This API uses an asynchronous callback to return the result.
3285
3286**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3287
3288**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3289
3290**Parameters**
3291
3292| Name  | Type                     | Mandatory| Description      |
3293| -------- | ------------------------- | ---- | ---------- |
3294| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the image and video assets.|
3295| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;&gt; | Yes  | Callback invoked to return the image and video assets obtained.|
3296
3297**Error codes**
3298
3299For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3300
3301| ID| Error Message|
3302| -------- | ---------------------------------------- |
3303| 13900020   | if type options is not FetchOptions.         |
3304
3305**Example**
3306
3307```ts
3308import dataSharePredicates from '@ohos.data.dataSharePredicates';
3309
3310async function example() {
3311  console.info('albumGetFileAssetsDemoCallback');
3312
3313  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3314  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
3315    predicates: predicates
3316  };
3317  let fetchOption: userFileManager.FetchOptions = {
3318    fetchColumns: [],
3319    predicates: predicates
3320  };
3321  let albumList: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(albumFetchOptions);
3322  let album: userFileManager.Album = await albumList.getFirstObject();
3323  album.getPhotoAssets(fetchOption, (err, albumFetchResult) => {
3324    if (albumFetchResult != undefined) {
3325      console.info('album getPhotoAssets successfully, getCount: ' + albumFetchResult.getCount());
3326    } else {
3327      console.error('album getPhotoAssets failed with error: ' + err);
3328    }
3329  });
3330}
3331```
3332
3333### getPhotoAssets
3334
3335getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
3336
3337Obtains image and video assets. This API uses a promise to return the result.
3338
3339**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3340
3341**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3342
3343**Parameters**
3344
3345| Name  | Type                     | Mandatory| Description      |
3346| -------- | ------------------------- | ---- | ---------- |
3347| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the image and video assets.|
3348
3349**Return value**
3350
3351| Type                                   | Description             |
3352| --------------------------------------- | ----------------- |
3353| Promise&lt;[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;&gt; | Promise used to return the image and video assets obtained.|
3354
3355**Error codes**
3356
3357For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3358
3359| ID| Error Message|
3360| -------- | ---------------------------------------- |
3361| 13900020   | if type options is not FetchOptions.         |
3362
3363**Example**
3364
3365```ts
3366import dataSharePredicates from '@ohos.data.dataSharePredicates';
3367import { BusinessError } from '@ohos.base';
3368
3369async function example() {
3370  console.info('albumGetFileAssetsDemoPromise');
3371
3372  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3373  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
3374    predicates: predicates
3375  };
3376  let fetchOption: userFileManager.FetchOptions = {
3377    fetchColumns: [],
3378    predicates: predicates
3379  };
3380  const albumList: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(albumFetchOptions);
3381  const album: userFileManager.Album = await albumList.getFirstObject();
3382  album.getPhotoAssets(fetchOption).then((albumFetchResult) => {
3383    console.info('album getFileAssets successfully, getCount: ' + albumFetchResult.getCount());
3384  }).catch((err: BusinessError) => {
3385    console.error('album getFileAssets failed with error: ' + err);
3386  });
3387}
3388```
3389
3390### commitModify
3391
3392commitModify(callback: AsyncCallback&lt;void&gt;): void;
3393
3394Commits the modification on the album attributes to the database. This API uses an asynchronous callback to return the result.
3395
3396**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3397
3398**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3399
3400**Parameters**
3401
3402| Name  | Type                     | Mandatory| Description      |
3403| -------- | ------------------------- | ---- | ---------- |
3404| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3405
3406**Example**
3407
3408```ts
3409import dataSharePredicates from '@ohos.data.dataSharePredicates';
3410
3411async function example() {
3412  console.info('albumCommitModifyDemo');
3413  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3414  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
3415    predicates: predicates
3416  };
3417  const albumList: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(albumFetchOptions);
3418  const album: userFileManager.Album = await albumList.getFirstObject();
3419  album.albumName = 'hello';
3420  album.commitModify((err) => {
3421    if (err != undefined) {
3422      console.error('commitModify failed with error: ' + err);
3423    } else {
3424      console.info('commitModify successfully');
3425    }
3426  });
3427}
3428```
3429
3430### commitModify
3431
3432commitModify(): Promise&lt;void&gt;;
3433
3434Commits the modification on the album attributes to the database. This API uses a promise to return the result.
3435
3436**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3437
3438**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3439
3440**Return value**
3441
3442| Type                 | Description          |
3443| ------------------- | ------------ |
3444| Promise&lt;void&gt; | Promise that returns no value.|
3445
3446**Example**
3447
3448```ts
3449import dataSharePredicates from '@ohos.data.dataSharePredicates';
3450import { BusinessError } from '@ohos.base';
3451
3452async function example() {
3453  console.info('albumCommitModifyDemo');
3454  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3455  let albumFetchOptions: userFileManager.AlbumFetchOptions = {
3456    predicates: predicates
3457  };
3458  try {
3459    let albumList: userFileManager.FetchResult<userFileManager.Album> = await mgr.getPhotoAlbums(albumFetchOptions);
3460    let album: userFileManager.Album = await albumList.getFirstObject();
3461    album.albumName = 'hello';
3462    album.commitModify().then(() => {
3463      console.info('commitModify successfully');
3464    }).catch((err: BusinessError) => {
3465      console.error('commitModify failed with error: ' + err);
3466    });
3467  } catch (err) {
3468    console.error('getPhotoAlbums failed. message = ', err);
3469  }
3470}
3471```
3472
3473### addPhotoAssets<sup>10+</sup>
3474
3475addPhotoAssets(assets: Array&lt;FileAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
3476
3477Adds 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.
3478
3479**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3480
3481**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3482
3483**Parameters**
3484
3485| Name  | Type                     | Mandatory| Description      |
3486| -------- | ------------------------- | ---- | ---------- |
3487| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image and video assets to add.|
3488| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3489
3490**Error codes**
3491
3492For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3493
3494| ID| Error Message|
3495| -------- | ---------------------------------------- |
3496| 13900020   | if PhotoAssets is invalid.         |
3497
3498**Example**
3499
3500```ts
3501import dataSharePredicates from '@ohos.data.dataSharePredicates';
3502
3503async function example() {
3504  try {
3505    console.info('addPhotoAssetsDemoCallback');
3506    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3507    let fetchOption: userFileManager.FetchOptions = {
3508      fetchColumns: [],
3509      predicates: predicates
3510    };
3511    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC);
3512    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3513    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3514    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3515    album.addPhotoAssets([asset], (err) => {
3516      if (err === undefined) {
3517        console.info('album addPhotoAssets successfully');
3518      } else {
3519        console.error('album addPhotoAssets failed with error: ' + err);
3520      }
3521    });
3522  } catch (err) {
3523    console.error('addPhotoAssetsDemoCallback failed with error: ' + err);
3524  }
3525}
3526```
3527
3528### addPhotoAssets<sup>10+</sup>
3529
3530addPhotoAssets(assets: Array&lt;FileAsset&gt;): Promise&lt;void&gt;;
3531
3532Adds 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.
3533
3534**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3535
3536**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3537
3538**Parameters**
3539
3540| Name  | Type                     | Mandatory| Description      |
3541| -------- | ------------------------- | ---- | ---------- |
3542| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image and video assets to add.|
3543
3544**Return value**
3545
3546| Type                                   | Description             |
3547| --------------------------------------- | ----------------- |
3548|Promise&lt;void&gt; | Promise that returns no value.|
3549
3550**Error codes**
3551
3552For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3553
3554| ID| Error Message|
3555| -------- | ---------------------------------------- |
3556| 13900020   | if PhotoAssets is invalid.         |
3557
3558**Example**
3559
3560```ts
3561import dataSharePredicates from '@ohos.data.dataSharePredicates';
3562import { BusinessError } from '@ohos.base';
3563
3564async function example() {
3565  try {
3566    console.info('addPhotoAssetsDemoPromise');
3567    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3568    let fetchOption: userFileManager.FetchOptions = {
3569      fetchColumns: [],
3570      predicates: predicates
3571    };
3572    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC);
3573    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3574    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await mgr.getPhotoAssets(fetchOption);
3575    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3576    album.addPhotoAssets([asset]).then(() => {
3577      console.info('album addPhotoAssets successfully');
3578    }).catch((err: BusinessError) => {
3579      console.error('album addPhotoAssets failed with error: ' + err);
3580    });
3581  } catch (err) {
3582    console.error('addPhotoAssetsDemoPromise failed with error: ' + err);
3583  }
3584}
3585```
3586
3587### removePhotoAssets<sup>10+</sup>
3588
3589removePhotoAssets(assets: Array&lt;FileAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
3590
3591Removes image and video assets from an album. The album and file resources must exist. This API uses an asynchronous callback to return the result.
3592
3593**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3594
3595**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3596
3597**Parameters**
3598
3599| Name  | Type                     | Mandatory| Description      |
3600| -------- | ------------------------- | ---- | ---------- |
3601| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image and video assets to remove.|
3602| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3603
3604**Error codes**
3605
3606For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3607
3608| ID| Error Message|
3609| -------- | ---------------------------------------- |
3610| 13900020   | if PhotoAssets is invalid.         |
3611
3612**Example**
3613
3614```ts
3615import dataSharePredicates from '@ohos.data.dataSharePredicates';
3616
3617async function example() {
3618  try {
3619    console.info('removePhotoAssetsDemoCallback');
3620    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3621    let fetchOption: userFileManager.FetchOptions = {
3622      fetchColumns: [],
3623      predicates: predicates
3624    };
3625    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC);
3626    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3627    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3628    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3629    album.removePhotoAssets([asset], (err) => {
3630      if (err === undefined) {
3631        console.info('album removePhotoAssets successfully');
3632      } else {
3633        console.error('album removePhotoAssets failed with error: ' + err);
3634      }
3635    });
3636  } catch (err) {
3637    console.error('removePhotoAssetsDemoCallback failed with error: ' + err);
3638  }
3639}
3640```
3641
3642### removePhotoAssets<sup>10+</sup>
3643
3644removePhotoAssets(assets: Array&lt;FileAsset&gt;): Promise&lt;void&gt;;
3645
3646Removes image and video assets from an album. The album and file resources must exist. This API uses a promise to return the result.
3647
3648**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3649
3650**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3651
3652**Parameters**
3653
3654| Name  | Type                     | Mandatory| Description      |
3655| -------- | ------------------------- | ---- | ---------- |
3656| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image and video assets to remove.|
3657
3658**Return value**
3659
3660| Type                                   | Description             |
3661| --------------------------------------- | ----------------- |
3662|Promise&lt;void&gt; | Promise that returns no value.|
3663
3664**Error codes**
3665
3666For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3667
3668| ID| Error Message|
3669| -------- | ---------------------------------------- |
3670| 13900020   | if PhotoAssets is invalid.         |
3671
3672**Example**
3673
3674```ts
3675import dataSharePredicates from '@ohos.data.dataSharePredicates';
3676import { BusinessError } from '@ohos.base';
3677
3678async function example() {
3679  try {
3680    console.info('removePhotoAssetsDemoPromise');
3681    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3682    let fetchOption: userFileManager.FetchOptions = {
3683      fetchColumns: [],
3684      predicates: predicates
3685    };
3686    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.USER, userFileManager.AlbumSubType.USER_GENERIC);
3687    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3688    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3689    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3690    album.removePhotoAssets([asset]).then(() => {
3691      console.info('album removePhotoAssets successfully');
3692    }).catch((err: BusinessError) => {
3693      console.error('album removePhotoAssets failed with error: ' + err);
3694    });
3695  } catch (err) {
3696    console.error('removePhotoAssetsDemoPromise failed with error: ' + err);
3697  }
3698}
3699```
3700
3701### recoverPhotoAssets<sup>10+</sup>
3702
3703recoverPhotoAssets(assets: Array&lt;FileAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
3704
3705Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
3706
3707**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3708
3709**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3710
3711**Parameters**
3712
3713| Name  | Type                     | Mandatory| Description      |
3714| -------- | ------------------------- | ---- | ---------- |
3715| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image or video assets to recover.|
3716| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3717
3718**Error codes**
3719
3720For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3721
3722| ID| Error Message|
3723| -------- | ---------------------------------------- |
3724| 13900020   | if PhotoAssets is invalid.         |
3725
3726**Example**
3727
3728```ts
3729import dataSharePredicates from '@ohos.data.dataSharePredicates';
3730
3731async function example() {
3732  try {
3733    console.info('recoverPhotoAssetsDemoCallback');
3734    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3735    let fetchOption: userFileManager.FetchOptions = {
3736      fetchColumns: [],
3737      predicates: predicates
3738    };
3739    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.TRASH);
3740    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3741    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3742    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3743    album.recoverPhotoAssets([asset], (err) => {
3744      if (err === undefined) {
3745        console.info('album recoverPhotoAssets successfully');
3746      } else {
3747        console.error('album recoverPhotoAssets failed with error: ' + err);
3748      }
3749    });
3750  } catch (err) {
3751    console.error('recoverPhotoAssetsDemoCallback failed with error: ' + err);
3752  }
3753}
3754```
3755
3756### recoverPhotoAssets<sup>10+</sup>
3757
3758recoverPhotoAssets(assets: Array&lt;FileAsset&gt;): Promise&lt;void&gt;;
3759
3760Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
3761
3762**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3763
3764**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3765
3766**Parameters**
3767
3768| Name  | Type                     | Mandatory| Description      |
3769| -------- | ------------------------- | ---- | ---------- |
3770| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image or video assets to recover.|
3771
3772**Return value**
3773
3774| Type                                   | Description             |
3775| --------------------------------------- | ----------------- |
3776|Promise&lt;void&gt; | Promise that returns no value.|
3777
3778**Error codes**
3779
3780For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3781
3782| ID| Error Message|
3783| -------- | ---------------------------------------- |
3784| 13900020   | if PhotoAssets is invalid.         |
3785
3786**Example**
3787
3788```ts
3789import dataSharePredicates from '@ohos.data.dataSharePredicates';
3790import { BusinessError } from '@ohos.base';
3791
3792async function example() {
3793  try {
3794    console.info('recoverPhotoAssetsDemoPromise');
3795    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3796    let fetchOption: userFileManager.FetchOptions = {
3797      fetchColumns: [],
3798      predicates: predicates
3799    };
3800    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.TRASH);
3801    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3802    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3803    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3804    album.recoverPhotoAssets([asset]).then(() => {
3805      console.info('album recoverPhotoAssets successfully');
3806    }).catch((err: BusinessError) => {
3807      console.error('album recoverPhotoAssets failed with error: ' + err);
3808    });
3809  } catch (err) {
3810    console.error('recoverPhotoAssetsDemoPromise failed with error: ' + err);
3811  }
3812}
3813```
3814
3815### deletePhotoAssets<sup>10+</sup>
3816
3817deletePhotoAssets(assets: Array&lt;FileAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
3818
3819Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
3820
3821**CAUTION**: This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
3822
3823**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3824
3825**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3826
3827**Parameters**
3828
3829| Name  | Type                     | Mandatory| Description      |
3830| -------- | ------------------------- | ---- | ---------- |
3831| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image or video assets to delete.|
3832| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3833
3834**Error codes**
3835
3836For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3837
3838| ID| Error Message|
3839| -------- | ---------------------------------------- |
3840| 13900020   | if PhotoAssets is invalid.         |
3841
3842**Example**
3843
3844```ts
3845import dataSharePredicates from '@ohos.data.dataSharePredicates';
3846
3847async function example() {
3848  try {
3849    console.info('deletePhotoAssetsDemoCallback');
3850    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3851    let fetchOption: userFileManager.FetchOptions = {
3852      fetchColumns: [],
3853      predicates: predicates
3854    };
3855    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.TRASH);
3856    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3857    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3858    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3859    album.deletePhotoAssets([asset], (err) => {
3860      if (err === undefined) {
3861        console.info('album deletePhotoAssets successfully');
3862      } else {
3863        console.error('album deletePhotoAssets failed with error: ' + err);
3864      }
3865    });
3866  } catch (err) {
3867    console.error('deletePhotoAssetsDemoCallback failed with error: ' + err);
3868  }
3869}
3870```
3871
3872### deletePhotoAssets<sup>10+</sup>
3873
3874deletePhotoAssets(assets: Array&lt;FileAsset&gt;): Promise&lt;void&gt;;
3875
3876Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
3877
3878**CAUTION**: This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
3879
3880**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3881
3882**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3883
3884**Parameters**
3885
3886| Name  | Type                     | Mandatory| Description      |
3887| -------- | ------------------------- | ---- | ---------- |
3888| assets | Array&lt;[FileAsset](#fileasset)&gt; | Yes  | Array of the image or video assets to delete.|
3889
3890**Return value**
3891
3892| Type                                   | Description             |
3893| --------------------------------------- | ----------------- |
3894|Promise&lt;void&gt; | Promise that returns no value.|
3895
3896**Error codes**
3897
3898For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3899
3900| ID| Error Message|
3901| -------- | ---------------------------------------- |
3902| 13900020   | if PhotoAssets is invalid.         |
3903
3904**Example**
3905
3906```ts
3907import dataSharePredicates from '@ohos.data.dataSharePredicates';
3908import { BusinessError } from '@ohos.base';
3909
3910async function example() {
3911  try {
3912    console.info('deletePhotoAssetsDemoPromise');
3913    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3914    let fetchOption: userFileManager.FetchOptions = {
3915      fetchColumns: [],
3916      predicates: predicates
3917    };
3918    let albumFetchResult: userFileManager.FetchResult<userFileManager.Album> = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.TRASH);
3919    let album: userFileManager.Album = await albumFetchResult.getFirstObject();
3920    let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await album.getPhotoAssets(fetchOption);
3921    let asset: userFileManager.FileAsset = await fetchResult.getFirstObject();
3922    album.deletePhotoAssets([asset]).then(() => {
3923      console.info('album deletePhotoAssets successfully');
3924    }).catch((err: BusinessError) => {
3925      console.error('album deletePhotoAssets failed with error: ' + err);
3926    });
3927  } catch (err) {
3928    console.error('deletePhotoAssetsDemoPromise failed with error: ' + err);
3929  }
3930}
3931```
3932
3933## PrivateAlbum
3934
3935Provides APIs for managing the system albums.
3936
3937This API will be discarded. Use [Album](#album) instead.
3938
3939### Attributes
3940
3941**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3942
3943| Name          | Type   | Readable  | Writable  | Description     |
3944| ------------ | ------ | ---- | ---- | ------- |
3945| albumName | string | Yes   | Yes   | Name of the album.   |
3946| albumUri | string | Yes   | No   | URI of the album.  |
3947| dateModified | number | Yes   | No   | Date when the album was last modified.   |
3948| count | number | Yes   | No   | Number of files in the album.|
3949| coverUri | string | Yes   | No   | URI of the cover file of the album.|
3950
3951### getPhotoAssets
3952
3953getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
3954
3955Obtains image and video assets from a system album. This API uses an asynchronous callback to return the result.
3956
3957This API will be deprecated. Use [Album.getPhotoAssets](#getphotoassets-2) instead.
3958
3959**Required permissions**: ohos.permission.READ_IMAGEVIDEO
3960
3961**System capability**: SystemCapability.FileManagement.UserFileManager.Core
3962
3963**Parameters**
3964
3965| Name  | Type                     | Mandatory| Description      |
3966| -------- | ------------------------- | ---- | ---------- |
3967| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the image and video assets.|
3968| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;&gt; | Yes  | Callback invoked to return the image and video assets obtained.|
3969
3970**Error codes**
3971
3972For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
3973
3974| ID| Error Message|
3975| -------- | ---------------------------------------- |
3976| 13900020   | if type options is not FetchOptions.         |
3977
3978**Example**
3979
3980```ts
3981import dataSharePredicates from '@ohos.data.dataSharePredicates';
3982
3983async function example() {
3984  console.info('privateAlbumGetFileAssetsDemoCallback');
3985  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
3986  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3987  let fetchOption: userFileManager.FetchOptions = {
3988    fetchColumns: [],
3989    predicates: predicates
3990  };
3991  const trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
3992  trashAlbum.getPhotoAssets(fetchOption, (err, fetchResult) => {
3993    if (fetchResult != undefined) {
3994      let count = fetchResult.getCount();
3995      console.info('fetchResult.count = ', count);
3996    } else {
3997      console.error('getFileAssets failed, message = ', err);
3998    }
3999  });
4000}
4001
4002```
4003
4004### getPhotoAssets
4005
4006getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
4007
4008Obtains image and video assets from a system album. This API uses a promise to return the result.
4009
4010This API will be deprecated. Use [Album.getPhotoAssets](#getphotoassets-3) instead.
4011
4012**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4013
4014**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4015
4016**Parameters**
4017
4018| Name  | Type                     | Mandatory| Description      |
4019| -------- | ------------------------- | ---- | ---------- |
4020| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the image and video assets.|
4021
4022**Return value**
4023
4024| Type                                   | Description             |
4025| --------------------------------------- | ----------------- |
4026| Promise:[FetchResult](#fetchresult)&lt;[FileAsset](#fileasset)&gt;| Promise used to return the image and video assets obtained.|
4027
4028**Error codes**
4029
4030For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
4031
4032| ID| Error Message|
4033| -------- | ---------------------------------------- |
4034| 13900020   | if type options is not FetchOptions.         |
4035
4036**Example**
4037
4038```ts
4039import dataSharePredicates from '@ohos.data.dataSharePredicates';
4040
4041async function example() {
4042  console.info('privateAlbumGetFileAssetsDemoPromise');
4043  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
4044  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4045  let fetchOption: userFileManager.FetchOptions = {
4046    fetchColumns: [],
4047    predicates: predicates
4048  };
4049  const trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
4050  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await trashAlbum.getPhotoAssets(fetchOption);
4051  let count = fetchResult.getCount();
4052  console.info('fetchResult.count = ', count);
4053}
4054```
4055
4056### delete
4057
4058delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
4059
4060Deletes a file from the system album. Only the files in the trash can be deleted.
4061
4062This API will be deprecated. Use [Album.deletePhotoAssets](#deletephotoassets10) instead.
4063
4064**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
4065
4066**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4067
4068**Parameters**
4069
4070| Name  | Type                     | Mandatory| Description      |
4071| -------- | ------------------------- | ---- | ---------- |
4072| uri | string | Yes  | URI of the file to delete.|
4073| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
4074
4075**Example**
4076
4077```ts
4078import dataSharePredicates from '@ohos.data.dataSharePredicates';
4079
4080async function example() {
4081  console.info('privateAlbumDeleteCallback');
4082  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
4083  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4084  let fetchOption: userFileManager.FetchOptions = {
4085    fetchColumns: [],
4086    predicates: predicates
4087  };
4088  let trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
4089  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await trashAlbum.getPhotoAssets(fetchOption);
4090  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
4091  let deleteFileUri = fileAsset.uri;
4092  trashAlbum.delete(deleteFileUri, (err) => {
4093    if (err != undefined) {
4094      console.error('trashAlbum.delete failed, message = ', err);
4095    } else {
4096      console.info('trashAlbum.delete successfully');
4097    }
4098  });
4099}
4100```
4101
4102### delete
4103
4104delete(uri: string): Promise&lt;void&gt;;
4105
4106Deletes a file from the system album. Only the files in the trash can be deleted.
4107
4108This API will be deprecated. Use [Album.deletePhotoAssets](#deletephotoassets10) instead.
4109
4110**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
4111
4112**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4113
4114**Parameters**
4115
4116| Name  | Type                     | Mandatory| Description      |
4117| -------- | ------------------------- | ---- | ---------- |
4118| uri | string | Yes  | URI of the file to delete.|
4119
4120**Return value**
4121
4122| Type                                   | Description             |
4123| --------------------------------------- | ----------------- |
4124| Promise&lt;void&gt;| Promise that returns no value.|
4125
4126**Example**
4127
4128```ts
4129import dataSharePredicates from '@ohos.data.dataSharePredicates';
4130import { BusinessError } from '@ohos.base';
4131
4132async function example() {
4133  console.info('privateAlbumDeleteDemoPromise');
4134  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
4135  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4136  let fetchOption: userFileManager.FetchOptions = {
4137    fetchColumns: [],
4138    predicates: predicates
4139  };
4140  let trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
4141  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await trashAlbum.getPhotoAssets(fetchOption);
4142  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
4143  let deleteFileUri = fileAsset.uri;
4144  trashAlbum.delete(deleteFileUri).then(() => {
4145    console.info('trashAlbum.delete successfully');
4146  }).catch((err: BusinessError) => {
4147    console.error('trashAlbum.delete failed, message = ', err);
4148  });
4149}
4150```
4151
4152### recover
4153
4154recover(uri: string, callback: AsyncCallback&lt;void&gt;): void;
4155
4156Recovers a file in the system album. Only the files in the trash can be recovered.
4157
4158This API will be deprecated. Use [Album.recoverPhotoAssets](#recoverphotoassets10) instead.
4159
4160**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
4161
4162**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4163
4164**Parameters**
4165
4166| Name  | Type                     | Mandatory| Description      |
4167| -------- | ------------------------- | ---- | ---------- |
4168| uri | string | Yes  | URI of the file to recover.|
4169| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
4170
4171**Example**
4172
4173```ts
4174import dataSharePredicates from '@ohos.data.dataSharePredicates';
4175
4176async function example() {
4177  console.info('privateAlbumRecoverDemoCallback');
4178  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
4179  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4180  let fetchOption: userFileManager.FetchOptions = {
4181    fetchColumns: [],
4182    predicates: predicates
4183  };
4184  let trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
4185  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await trashAlbum.getPhotoAssets(fetchOption);
4186  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
4187  let recoverFileUri: string = fileAsset.uri;
4188  trashAlbum.recover(recoverFileUri, (err) => {
4189    if (err != undefined) {
4190      console.error('trashAlbum.recover failed, message = ', err);
4191    } else {
4192      console.info('trashAlbum.recover successfully');
4193    }
4194  });
4195}
4196```
4197
4198### recover
4199
4200recover(uri: string): Promise&lt;void&gt;;
4201
4202Recovers a file in the system album. Only the files in the trash can be recovered.
4203
4204This API will be deprecated. Use [Album.recoverPhotoAssets](#recoverphotoassets10) instead.
4205
4206**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO, and ohos.permission.WRITE_AUDIO
4207
4208**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4209
4210**Parameters**
4211
4212| Name  | Type                     | Mandatory| Description      |
4213| -------- | ------------------------- | ---- | ---------- |
4214| uri | string | Yes  | URI of the file to recover.|
4215
4216**Return value**
4217
4218| Type                                   | Description             |
4219| --------------------------------------- | ----------------- |
4220| Promise&lt;void&gt;| Promise that returns no value.|
4221
4222**Example**
4223
4224```ts
4225import dataSharePredicates from '@ohos.data.dataSharePredicates';
4226import { BusinessError } from '@ohos.base';
4227
4228async function example() {
4229  console.info('privateAlbumRecoverDemoPromise');
4230  let albumList: userFileManager.FetchResult<userFileManager.PrivateAlbum> = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH);
4231  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4232  let fetchOption: userFileManager.FetchOptions = {
4233    fetchColumns: [],
4234    predicates: predicates
4235  };
4236  let trashAlbum: userFileManager.PrivateAlbum = await albumList.getFirstObject();
4237  let fetchResult: userFileManager.FetchResult<userFileManager.FileAsset> = await trashAlbum.getPhotoAssets(fetchOption);
4238  let fileAsset: userFileManager.FileAsset = await fetchResult.getFirstObject();
4239  let recoverFileUri: string = fileAsset.uri;
4240  trashAlbum.recover(recoverFileUri).then(() => {
4241    console.info('trashAlbum.recover successfully');
4242  }).catch((err: BusinessError) => {
4243    console.error('trashAlbum.recover failed, message = ', err);
4244  });
4245}
4246```
4247
4248## MemberType
4249
4250Enumerates the member types.
4251
4252**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4253
4254| Name |  Type|  Readable |  Writable |  Description |
4255| ----- |  ---- |  ---- |  ---- |  ---- |
4256| number |  number | Yes| Yes| The member is a number.|
4257| string |  string | Yes| Yes| The member is a string.|
4258| boolean |  boolean | Yes| Yes| The member is a Boolean value.|
4259
4260## ChangeEvent
4261
4262Enumerates the type of changes to observe.
4263
4264**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4265
4266| Name |  Type|  Readable |  Writable |  Description|
4267| ----- |  ---- |  ---- |  ---- |  ---- |
4268| deviceChange |  string | Yes| Yes|  Device change.|
4269| albumChange |  string | Yes| Yes|  Album change.|
4270| imageChange |  string | Yes| Yes|  Image change.|
4271| audioChange |  string | Yes| Yes|  Audio change.|
4272| videoChange |  string | Yes| Yes|  Video change.|
4273| remoteFileChange |  string | Yes| Yes|  Remote file change.|
4274
4275## PeerInfo
4276
4277Defines information about a registered device.
4278
4279**System capability**: SystemCapability.FileManagement.UserFileManager.DistributedCore
4280
4281| Name      | Type                      | Readable| Writable| Description            |
4282| ---------- | -------------------------- | ---- | ---- | ---------------- |
4283| deviceName | string                     | Yes  | No  | Name of the registered device.  |
4284| networkId  | string                     | Yes  | No  | Network ID of the registered device.|
4285| isOnline   | boolean                    | Yes  | No  | Whether the registered device is online.        |
4286
4287## FileType
4288
4289Enumerates media file types.
4290
4291**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4292
4293| Name |  Value|  Description|
4294| ----- |  ---- |  ---- |
4295| IMAGE |  1 |  Image.|
4296| VIDEO |  2 |  Video.|
4297| AUDIO |  3 |  Audio.|
4298
4299## PhotoSubType<sup>10+</sup>
4300
4301Enumerates the [FileAsset](#fileasset) types.
4302
4303**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4304
4305| Name |  Value|  Description|
4306| ----- |  ---- |  ---- |
4307| DEFAULT |  0 |  Default (photo) type.|
4308| SCREENSHOT |  1 |  Screenshots and screen recording files.|
4309| CAMERA |  2 |  Photos and videos taken by a camera.|
4310
4311## PositionType<sup>10+</sup>
4312
4313Enumerates the file location.
4314
4315**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4316
4317| Name |  Value|  Description|
4318| ----- |  ---- |  ---- |
4319| LOCAL |  1 |  Stored only on a local device.|
4320| CLOUD |  2 |  Stored only on the cloud.|
4321| BOTH |  3 |  Stored both on a local device and the cloud.|
4322
4323## AlbumType<sup>10+</sup>
4324
4325Enumerates the album types.
4326
4327**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4328
4329| Name |  Value|  Description|
4330| ----- |  ---- |  ---- |
4331| USER |  0 |  User album.|
4332| SYSTEM |  1024 |  System album.|
4333
4334## AlbumSubType<sup>10+</sup>
4335
4336Enumerate the album subtypes.
4337
4338**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4339
4340| Name |  Value|  Description|
4341| ----- |  ---- |  ---- |
4342| USER_GENERIC |  1 |  User album.|
4343| FAVORITE |  1025 |  Favorites.|
4344| VIDEO |  1026 |  Video album.|
4345| HIDDEN |  1027 |  Hidden album.|
4346| TRASH |  1028 |  Recycle bin.|
4347| SCREENSHOT |  1029 |  Album for screenshots and screen recording files.|
4348| CAMERA |  1030 |  Album for photos and videos taken by the camera.|
4349| ANY |  2147483647 |  Any album.|
4350
4351## PrivateAlbumType
4352
4353Enumerates the system album types.
4354
4355This API will be deprecated. Use [AlbumType](#albumtype10) and [AlbumSubType](#albumsubtype10)  instead.
4356
4357**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4358
4359| Name   |  Value|   Description  |
4360| -----   |  ----  |   ----  |
4361| TYPE_FAVORITE |  0 |  Favorites.|
4362| TYPE_TRASH |  1 |  Recycle bin.|
4363
4364## AudioKey
4365
4366Defines the key information about an audio file.
4367
4368**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4369
4370| Name         |   Value             | Description                                                      |
4371| ------------- | ------------------- | ---------------------------------------------------------- |
4372| URI           | uri                 | URI of the file.                                                  |
4373| DISPLAY_NAME  | display_name        | File name displayed.                                                  |
4374| 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).            |
4375| 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.|
4376| TITLE         | title               | Title in the file.                                                  |
4377| ARTIST        | artist              | Author of the file.                                                  |
4378| AUDIOALBUM    | audio_album         | Audio album.                                                  |
4379| DURATION      | duration            | Duration, in ms.                                   |
4380| FAVORITE      | favorite            | Whether the file is added to favorites.                                                  |
4381
4382## ImageVideoKey
4383
4384Defines the key information about an image or video file.
4385
4386**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4387
4388| Name         | Value             | Description                                                      |
4389| ------------- | ------------------- | ---------------------------------------------------------- |
4390| URI           | uri                 | URI of the file.                                                  |
4391| FILE_TYPE     | file_type           | Type of the file.                                             |
4392| DISPLAY_NAME  | display_name        | File name displayed.                                                  |
4393| DATE_ADDED    | date_added          | Date when the file was added. The value is the number of seconds elapsed since the Epoch time.            |
4394| 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.|
4395| TITLE         | title               | Title of the file.                                                  |
4396| DURATION      | duration            | Duration, in ms.                                   |
4397| WIDTH         | width               | Image width, in pixels.                                   |
4398| HEIGHT        | height              | Image height, in pixels.                                     |
4399| DATE_TAKEN    | date_taken          | Date when the file (photo) was taken. The value is the number of seconds elapsed since the Epoch time.               |
4400| ORIENTATION   | orientation         | Orientation of the image file.                                            |
4401| FAVORITE      | favorite            | Whether the file is added to favorites.                                                   |
4402| POSITION<sup>10+</sup>  | position            | File location type.                              |
4403| DATE_TRASHED<sup>10+</sup>  | date_trashed  | Date when the file was deleted. The value is the number of seconds elapsed since the Epoch time.                |
4404| HIDDEN<sup>10+</sup>  | hidden            | Whether the file is hidden.                              |
4405| CAMERA_SHOT_KEY<sup>10+</sup>    | camera_shot_key           | Key for the Ultra Snapshot feature, which allows 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.)   |
4406| USER_COMMENT<sup>10+</sup>  | user_comment            | User comment information.                              |
4407
4408## AlbumKey
4409
4410Defines the key album information.
4411
4412**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4413
4414| Name         | Value             | Description                                                      |
4415| ------------- | ------------------- | ---------------------------------------------------------- |
4416| URI           | uri                 | URI of the album.                                                  |
4417| FILE_TYPE     | file_type           | Type of the file.                                             |
4418| ALBUM_NAME    | album_name          | Name of the album.                                                  |
4419| DATE_ADDED    | date_added          | Date when the album was added. The value is the number of seconds elapsed since the Epoch time.            |
4420| DATE_MODIFIED | date_modified       | Date when the album file content (not the album name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
4421
4422## PhotoCreateOptions<sup>10+</sup>
4423
4424Options for creating an image or video asset.
4425
4426**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4427
4428| Name                  | Type               | Mandatory| Description                                             |
4429| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
4430| subType           | [PhotoSubType](#photosubtype10) | No | Subtype of the image or video. |
4431| cameraShotKey           | string | No | Key for the Ultra Snapshot feature, which allows 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.) |
4432
4433## FetchOptions
4434
4435Defines the options for fetching media files.
4436
4437**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4438
4439| Name                  | Type               | Readable| Writable| Description                                             |
4440| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
4441| fetchColumns           | Array&lt;string&gt; | Yes  | Yes  | Options for fetching files based on the attributes in columns.<br>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.<br>Example: fetchColumns: ['uri', 'title']|
4442| predicates           | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md) | Yes  | Yes  | Predicates that specify the fetch criteria.|
4443
4444## AlbumFetchOptions
4445
4446Defines the options for fetching an album.
4447
4448**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4449
4450| Name                  | Type               | Readable| Writable| Description                                             |
4451| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
4452| predicates           | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md) | Yes  | Yes  | Predicates that specify the fetch criteria.|
4453
4454## ChangeData<sup>10+</sup>
4455
4456Defines the return value of the listener callback.
4457
4458**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4459
4460| Name   | Type                       | Readable| Writable| Description                                                        |
4461| ------- | --------------------------- | ---- | ---- | ------------------------------------------------------------ |
4462| type    | [NotifyType](#notifytype10) | Yes  | No  | Notification type.                                      |
4463| uris    | Array&lt;string&gt;         | Yes  | No  | Array of all file asset or album URIs with the same [NotifyType](#notifytype10).|
4464| subUris | Array&lt;string&gt;         | Yes  | No  | URIs of the changed files in the album.                                   |
4465
4466## NotifyType<sup>10+</sup>
4467
4468Enumerates the notification event types.
4469
4470**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4471
4472| Name                     | Value  | Description                            |
4473| ------------------------- | ---- | -------------------------------- |
4474| NOTIFY_ADD                | 0    | A file asset or album is added.    |
4475| NOTIFY_UPDATE             | 1    | A file asset or album is updated.    |
4476| NOTIFY_REMOVE             | 2    | A file asset or album is removed.    |
4477| NOTIFY_ALBUM_ADD_ASSET    | 3    | A file asset is added to the album.|
4478| NOTIFY_ALBUM_REMOVE_ASSET | 4    | A file asset is removed from the album.|
4479
4480## DefaultChangeUri<sup>10+</sup>
4481
4482Enumerates the **DefaultChangeUri** subtypes.
4483
4484**System capability**: SystemCapability.FileManagement.UserFileManager.Core
4485
4486| Name             | Value                     | Description                                                        |
4487| ----------------- | ----------------------- | ------------------------------------------------------------ |
4488| DEFAULT_PHOTO_URI | file://media/Photo      | Default **PhotoAsset** URI. The **PhotoAsset** change notifications are received based on this parameter and **forSubUri{true}**.|
4489| DEFAULT_ALBUM_URI | file://media/PhotoAlbum | Default album URI. Album change notifications are received based on this parameter and **forSubUri{true}**. |
4490| DEFAULT_AUDIO_URI | file://media/Audio      | Default **AudioAsset** URI. The **AudioAsset** change notifications are received based on this parameter and **forSubUri{true}**.|
4491