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