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