1# Interface (FetchResult) 2 3> **NOTE** 4> 5> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 6 7FetchResult provides APIs to manage the file retrieval result. 8 9## Modules to Import 10 11```ts 12import { photoAccessHelper } from '@kit.MediaLibraryKit'; 13``` 14 15## getCount 16 17getCount(): number 18 19Obtains the total number of files in the result set. 20 21**Atomic service API**: This API can be used in atomic services since API version 20. 22 23**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 24 25**Return value** 26 27| Type | Description | 28| ------ | -------- | 29| number | Returns the total number of files obtained.| 30 31**Error codes** 32 33For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 34 35| ID| Error Message| 36| -------- | ---------------------------------------- | 37| 13900020 | Invalid argument. | 38| 14000011 | System inner fail. | 39 40**Example** 41 42For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 43 44```ts 45import { dataSharePredicates } from '@kit.ArkData'; 46 47async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 48 console.info('getCountDemo'); 49 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 50 let fetchOption: photoAccessHelper.FetchOptions = { 51 fetchColumns: [], 52 predicates: predicates 53 }; 54 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 55 let fetchCount = fetchResult.getCount(); 56 console.info('fetchCount = ', fetchCount); 57} 58``` 59 60## isAfterLast 61 62isAfterLast(): boolean 63 64Checks whether the cursor is in the last row of the result set. 65 66**Atomic service API**: This API can be used in atomic services since API version 20. 67 68**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 69 70**Return value** 71 72| Type | Description | 73| ------- | ---------------------------------- | 74| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.| 75 76**Error codes** 77 78For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 79 80| ID| Error Message| 81| -------- | ---------------------------------------- | 82| 13900020 | Invalid argument. | 83| 14000011 | System inner fail. | 84 85**Example** 86 87For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 88 89```ts 90import { dataSharePredicates } from '@kit.ArkData'; 91 92async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 93 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 94 let fetchOption: photoAccessHelper.FetchOptions = { 95 fetchColumns: [], 96 predicates: predicates 97 }; 98 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 99 let fetchCount = fetchResult.getCount(); 100 console.info('count:' + fetchCount); 101 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject(); 102 if (fetchResult.isAfterLast()) { 103 console.info('photoAsset isAfterLast displayName = ', photoAsset.displayName); 104 } else { 105 console.info('photoAsset not isAfterLast.'); 106 } 107} 108``` 109 110## close 111 112close(): void 113 114Closes this FetchResult instance to invalidate it. After this instance is released, the APIs in this instance cannot be invoked. 115 116**Atomic service API**: This API can be used in atomic services since API version 20. 117 118**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 119 120**Error codes** 121 122For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 123 124| ID| Error Message| 125| -------- | ---------------------------------------- | 126| 13900020 | Invalid argument. | 127| 14000011 | System inner fail. | 128 129**Example** 130 131For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 132 133```ts 134import { dataSharePredicates } from '@kit.ArkData'; 135 136async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 137 console.info('fetchResultCloseDemo'); 138 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 139 let fetchOption: photoAccessHelper.FetchOptions = { 140 fetchColumns: [], 141 predicates: predicates 142 }; 143 try { 144 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 145 fetchResult.close(); 146 console.info('close succeed.'); 147 } catch (err) { 148 console.error(`close fail. error: ${err.code}, ${err.message}`); 149 } 150} 151``` 152 153## getFirstObject 154 155getFirstObject(callback: AsyncCallback<T>): void 156 157Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result. 158 159**Atomic service API**: This API can be used in atomic services since API version 20. 160 161**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 162 163**Parameters** 164 165| Name | Type | Mandatory| Description | 166| -------- | --------------------------------------------- | ---- | ------------------------------------------- | 167| callback | AsyncCallback<T> | Yes | Callback used to return the first file asset obtained.| 168 169**Error codes** 170 171For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 172 173| ID| Error Message| 174| -------- | ---------------------------------------- | 175| 13900020 | Invalid argument. | 176| 14000011 | System inner fail. | 177 178**Example** 179 180For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 181 182```ts 183import { dataSharePredicates } from '@kit.ArkData'; 184 185async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 186 console.info('getFirstObjectDemo'); 187 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 188 let fetchOption: photoAccessHelper.FetchOptions = { 189 fetchColumns: [], 190 predicates: predicates 191 }; 192 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 193 fetchResult.getFirstObject((err, photoAsset) => { 194 if (photoAsset !== undefined) { 195 console.info('photoAsset displayName: ', photoAsset.displayName); 196 } else { 197 console.error(`photoAsset failed with err:${err.code}, ${err.message}`); 198 } 199 }); 200} 201``` 202 203## getFirstObject 204 205getFirstObject(): Promise<T> 206 207Obtains the first file asset in the result set. This API uses a promise to return the result. 208 209**Atomic service API**: This API can be used in atomic services since API version 20. 210 211**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 212 213**Return value** 214 215| Type | Description | 216| --------------------------------------- | -------------------------- | 217| Promise<T> | Promise used to return the first object in the result set.| 218 219**Error codes** 220 221For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 222 223| ID| Error Message| 224| -------- | ---------------------------------------- | 225| 13900020 | Invalid argument. | 226| 14000011 | System inner fail. | 227 228**Example** 229 230For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 231 232```ts 233import { dataSharePredicates } from '@kit.ArkData'; 234 235async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 236 console.info('getFirstObjectDemo'); 237 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 238 let fetchOption: photoAccessHelper.FetchOptions = { 239 fetchColumns: [], 240 predicates: predicates 241 }; 242 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 243 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 244 console.info('photoAsset displayName: ', photoAsset.displayName); 245} 246``` 247 248## getNextObject 249 250getNextObject(callback: AsyncCallback<T>): void 251 252Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result. 253Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set. 254 255**Atomic service API**: This API can be used in atomic services since API version 20. 256 257**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 258 259**Parameters** 260 261| Name | Type | Mandatory| Description | 262| --------- | --------------------------------------------- | ---- | ----------------------------------------- | 263| callback | AsyncCallback<T> | Yes | Callback used to return the next file asset obtained.| 264 265**Error codes** 266 267For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 268 269| ID| Error Message| 270| -------- | ---------------------------------------- | 271| 13900020 | Invalid argument. | 272| 14000011 | System inner fail. | 273 274**Example** 275 276For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 277 278```ts 279import { dataSharePredicates } from '@kit.ArkData'; 280 281async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 282 console.info('getNextObjectDemo'); 283 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 284 let fetchOption: photoAccessHelper.FetchOptions = { 285 fetchColumns: [], 286 predicates: predicates 287 }; 288 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 289 await fetchResult.getFirstObject(); 290 if (!fetchResult.isAfterLast()) { 291 fetchResult.getNextObject((err, photoAsset) => { 292 if (photoAsset !== undefined) { 293 console.info('photoAsset displayName: ', photoAsset.displayName); 294 } else { 295 console.error(`photoAsset failed with err: ${err.code}, ${err.message}`); 296 } 297 }); 298 } 299} 300``` 301 302## getNextObject 303 304getNextObject(): Promise<T> 305 306Obtains the next file asset in the result set. This API uses a promise to return the result. 307Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set. 308 309**Atomic service API**: This API can be used in atomic services since API version 20. 310 311**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 312 313**Return value** 314 315| Type | Description | 316| --------------------------------------- | ----------------- | 317| Promise<T> | Promise used to return the next object in the result set.| 318 319**Error codes** 320 321For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 322 323| ID| Error Message| 324| -------- | ---------------------------------------- | 325| 13900020 | Invalid argument. | 326| 14000011 | System inner fail. | 327 328**Example** 329 330For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 331 332```ts 333import { dataSharePredicates } from '@kit.ArkData'; 334 335async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 336 console.info('getNextObjectDemo'); 337 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 338 let fetchOption: photoAccessHelper.FetchOptions = { 339 fetchColumns: [], 340 predicates: predicates 341 }; 342 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 343 await fetchResult.getFirstObject(); 344 if (!fetchResult.isAfterLast()) { 345 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getNextObject(); 346 console.info('photoAsset displayName: ', photoAsset.displayName); 347 } 348} 349``` 350 351## getLastObject 352 353getLastObject(callback: AsyncCallback<T>): void 354 355Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result. 356 357**Atomic service API**: This API can be used in atomic services since API version 20. 358 359**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 360 361**Parameters** 362 363| Name | Type | Mandatory| Description | 364| -------- | --------------------------------------------- | ---- | --------------------------- | 365| callback | AsyncCallback<T> | Yes | Callback used to return the last file asset obtained.| 366 367**Error codes** 368 369For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 370 371| ID| Error Message| 372| -------- | ---------------------------------------- | 373| 13900020 | Invalid argument. | 374| 14000011 | System inner fail. | 375 376**Example** 377 378For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 379 380```ts 381import { dataSharePredicates } from '@kit.ArkData'; 382 383async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 384 console.info('getLastObjectDemo'); 385 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 386 let fetchOption: photoAccessHelper.FetchOptions = { 387 fetchColumns: [], 388 predicates: predicates 389 }; 390 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 391 fetchResult.getLastObject((err, photoAsset) => { 392 if (photoAsset !== undefined) { 393 console.info('photoAsset displayName: ', photoAsset.displayName); 394 } else { 395 console.error(`photoAsset failed with err: ${err.code}, ${err.message}`); 396 } 397 }); 398} 399``` 400 401## getLastObject 402 403getLastObject(): Promise<T> 404 405Obtains the last file asset in the result set. This API uses a promise to return the result. 406 407**Atomic service API**: This API can be used in atomic services since API version 20. 408 409**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 410 411**Return value** 412 413| Type | Description | 414| --------------------------------------- | ----------------- | 415| Promise<T> | Promise used to return the last object in the result set.| 416 417**Error codes** 418 419For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 420 421| ID| Error Message| 422| -------- | ---------------------------------------- | 423| 13900020 | Invalid argument. | 424| 14000011 | System inner fail. | 425 426**Example** 427 428For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 429 430```ts 431import { dataSharePredicates } from '@kit.ArkData'; 432 433async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 434 console.info('getLastObjectDemo'); 435 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 436 let fetchOption: photoAccessHelper.FetchOptions = { 437 fetchColumns: [], 438 predicates: predicates 439 }; 440 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 441 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject(); 442 console.info('photoAsset displayName: ', photoAsset.displayName); 443} 444``` 445 446## getObjectByPosition 447 448getObjectByPosition(index: number, callback: AsyncCallback<T>): void 449 450Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result. 451 452**Atomic service API**: This API can be used in atomic services since API version 20. 453 454**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 455 456**Parameters** 457 458| Name | Type | Mandatory | Description | 459| -------- | ---------------------------------------- | ---- | ------------------ | 460| index | number | Yes | Index of the file asset to obtain. The value starts from **0**. | 461| callback | AsyncCallback<T> | Yes | Callback used to return the file asset obtained.| 462 463**Error codes** 464 465For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 466 467| ID| Error Message| 468| -------- | ---------------------------------------- | 469| 13900020 | Invalid argument. | 470| 14000011 | System inner fail. | 471 472**Example** 473 474For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 475 476```ts 477import { dataSharePredicates } from '@kit.ArkData'; 478 479async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 480 console.info('getObjectByPositionDemo'); 481 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 482 let fetchOption: photoAccessHelper.FetchOptions = { 483 fetchColumns: [], 484 predicates: predicates 485 }; 486 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 487 fetchResult.getObjectByPosition(0, (err, photoAsset) => { 488 if (photoAsset !== undefined) { 489 console.info('photoAsset displayName: ', photoAsset.displayName); 490 } else { 491 console.error(`photoAsset failed with err: ${err.code}, ${err.message}`); 492 } 493 }); 494} 495``` 496 497## getObjectByPosition 498 499getObjectByPosition(index: number): Promise<T> 500 501Obtains a file asset with the specified index in the result set. This API uses a promise to return the result. 502 503**Atomic service API**: This API can be used in atomic services since API version 20. 504 505**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 506 507**Parameters** 508 509| Name | Type | Mandatory | Description | 510| ----- | ------ | ---- | -------------- | 511| index | number | Yes | Index of the file asset to obtain. The value starts from **0**.| 512 513**Return value** 514 515| Type | Description | 516| --------------------------------------- | ----------------- | 517| Promise<T> | Promise used to return the file asset obtained.| 518 519**Error codes** 520 521For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 522 523| ID| Error Message| 524| -------- | ---------------------------------------- | 525| 13900020 | Invalid argument. | 526| 14000011 | System inner fail. | 527 528**Example** 529 530For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 531 532```ts 533import { dataSharePredicates } from '@kit.ArkData'; 534 535async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 536 console.info('getObjectByPositionDemo'); 537 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 538 let fetchOption: photoAccessHelper.FetchOptions = { 539 fetchColumns: [], 540 predicates: predicates 541 }; 542 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 543 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getObjectByPosition(0); 544 console.info('photoAsset displayName: ', photoAsset.displayName); 545} 546``` 547 548## getAllObjects 549 550getAllObjects(callback: AsyncCallback<Array<T>>): void 551 552Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result. 553 554**Atomic service API**: This API can be used in atomic services since API version 20. 555 556**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 557 558**Parameters** 559 560| Name | Type | Mandatory| Description | 561| -------- | --------------------------------------------- | ---- | ------------------------------------------- | 562| callback | AsyncCallback<Array<T>> | Yes | Callback used to return an array of all file assets in the result set.| 563 564**Error codes** 565 566For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 567 568| ID| Error Message| 569| -------- | ---------------------------------------- | 570| 13900020 | Invalid argument. | 571| 14000011 | System inner fail. | 572 573**Example** 574 575For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 576 577```ts 578import { dataSharePredicates } from '@kit.ArkData'; 579 580async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 581 console.info('getAllObjectDemo'); 582 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 583 let fetchOption: photoAccessHelper.FetchOptions = { 584 fetchColumns: [], 585 predicates: predicates 586 }; 587 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 588 fetchResult.getAllObjects((err, photoAssetList) => { 589 if (photoAssetList !== undefined) { 590 console.info('photoAssetList length: ', photoAssetList.length); 591 } else { 592 console.error(`photoAssetList failed with err:${err.code}, ${err.message}`); 593 } 594 }); 595} 596``` 597 598## getAllObjects 599 600getAllObjects(): Promise<Array<T>> 601 602Obtains all the file assets in the result set. This API uses a promise to return the result. 603 604**Atomic service API**: This API can be used in atomic services since API version 20. 605 606**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 607 608**Return value** 609 610| Type | Description | 611| --------------------------------------- | -------------------------- | 612| Promise<Array<T>> | Promise used to return an array of all file assets.| 613 614**Error codes** 615 616For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 617 618| ID| Error Message| 619| -------- | ---------------------------------------- | 620| 13900020 | Invalid argument. | 621| 14000011 | System inner fail. | 622 623**Example** 624 625For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper). 626 627```ts 628import { dataSharePredicates } from '@kit.ArkData'; 629 630async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) { 631 console.info('getAllObjectDemo'); 632 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 633 let fetchOption: photoAccessHelper.FetchOptions = { 634 fetchColumns: [], 635 predicates: predicates 636 }; 637 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 638 let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects(); 639 console.info('photoAssetList length: ', photoAssetList.length); 640} 641``` 642