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