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