• 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
17
18addContact(contact:Contact, callback:AsyncCallback<number>): 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| contact  | [Contact](#contact)         | Yes  | Contact information.                  |
31| callback | AsyncCallback<number> | Yes  | Callback used to return the contact ID.|
32
33**Example**
34
35  ```js
36  contact.addContact({
37      name: {fullName: 'xxx'},
38      phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
39  }, (err, data) => {
40      if (err) {
41          console.log(`addContact callback: err->${JSON.stringify(err)}`);
42          return;
43      }
44      console.log(`addContact callback: success data->${JSON.stringify(data)}`);
45  });
46  ```
47
48
49## contact.addContact
50
51addContact(contact: Contact): Promise<number>
52
53Adds a contact. This API uses a promise to return the result.
54
55**Permission required**: ohos.permission.WRITE_CONTACTS
56
57**System capability**: SystemCapability.Applications.ContactsData
58
59**Parameters**
60
61| Name | Type               | Mandatory| Description        |
62| ------- | ------------------- | ---- | ------------ |
63| contact | [Contact](#contact) | Yes  | Contact information.|
64
65**Return Value**
66
67| Type                 | Description                                       |
68| --------------------- | ------------------------------------------- |
69| Promise<number> | Promise used to return the contact ID.|
70
71**Example**
72
73  ```js
74  let promise = contact.addContact({
75      name: {fullName: 'xxx'},
76      phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
77  });
78  promise.then((data) => {
79      console.log(`addContact success: data->${JSON.stringify(data)}`);
80  }).catch((err) => {
81      console.error(`addContact fail: err->${JSON.stringify(err)}`);
82  });
83  ```
84
85
86## contact.deleteContact
87
88deleteContact(key: string, callback: AsyncCallback<void>): void
89
90Deletes a contact based on the specified contact key. This API uses an asynchronous callback to return the result.
91
92**Permission required**: ohos.permission.WRITE_CONTACTS
93
94**System capability**: SystemCapability.Applications.ContactsData
95
96**Parameters**
97
98| Name  | Type                     | Mandatory| Description                                |
99| -------- | ------------------------- | ---- | ------------------------------------ |
100| key      | string                    | Yes  | Contact key. Each contact corresponds to one key.|
101| callback | AsyncCallback<void> | Yes  | Callback used to return the result.    |
102
103**Example**
104
105  ```js
106  contact.deleteContact('xxx', (err) => {
107      if (err) {
108          console.log(`deleteContact callback: err->${JSON.stringify(err)}`);
109          return;
110      }
111      console.log('deleteContact success');
112  });
113  ```
114
115
116## contact.deleteContact
117
118deleteContact(key: string): Promise<void>
119
120Deletes a contact based on the specified contact key. This API uses a promise to return the result.
121
122**Permission required**: ohos.permission.WRITE_CONTACTS
123
124**System capability**: SystemCapability.Applications.ContactsData
125
126**Parameters**
127
128| Name| Type  | Mandatory| Description                                  |
129| ------ | ------ | ---- | -------------------------------------- |
130| key    | string | Yes  | Contact key. Each contact corresponds to one key.|
131
132**Return Value**
133
134| Type               | Description                                         |
135| ------------------- | --------------------------------------------- |
136| Promise<void> | Promise used to return the result.|
137
138**Example**
139
140  ```js
141  let promise = contact.deleteContact('xxx');
142  promise.then(() => {
143      console.log(`deleteContact success`);
144  }).catch((err) => {
145      console.error(`deleteContact fail: err->${JSON.stringify(err)}`);
146  });
147  ```
148
149
150## contact.updateContact
151
152updateContact(contact: Contact, callback: AsyncCallback<void>): void
153
154Updates a contact based on the specified contact information. This API uses an asynchronous callback to return the result.
155
156**Permission required**: ohos.permission.WRITE_CONTACTS
157
158**System capability**: SystemCapability.Applications.ContactsData
159
160**Parameters**
161
162| Name  | Type                     | Mandatory| Description                                |
163| -------- | ------------------------- | ---- | ------------------------------------ |
164| contact  | [Contact](#contact)       | Yes  | Contact information.                        |
165| callback | AsyncCallback<void> | Yes  | Callback used to return the result.|
166
167**Example**
168
169  ```js
170  contact.updateContact({
171      id: 1,
172      name: {fullName: 'xxx'},
173      phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
174  }, (err) => {
175      if (err) {
176          console.log('updateContact callback: err->${JSON.stringify(err)}');
177          return;
178      }
179      console.log('updateContact success');
180  });
181  ```
182
183
184## contact.updateContact
185
186updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallback<void>): void
187
188Updates a contact based on the specified contact information. This API uses an asynchronous callback to return the result.
189
190**Permission required**: ohos.permission.WRITE_CONTACTS
191
192**System capability**: SystemCapability.Applications.ContactsData
193
194**Parameters**
195
196| Name  | Type                                   | Mandatory| Description                                |
197| -------- | --------------------------------------- | ---- | ------------------------------------ |
198| contact  | [Contact](#contact)                     | Yes  | Contact information.                        |
199| attrs    | [ContactAttributes](#contactattributes) | Yes  | List of contact attributes.                  |
200| callback | AsyncCallback<void>               | Yes  | Callback used to return the result.|
201
202**Example**
203
204  ```js
205  contact.updateContact({
206      id: 1,
207      name: {fullName: 'xxx'},
208      phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
209  }, {
210      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
211  }, (err) => {
212      if (err) {
213          console.log('updateContact callback: err->${JSON.stringify(err)}');
214          return;
215      }
216      console.log('updateContact success');
217  });
218  ```
219
220
221## contact.updateContact
222
223updateContact(contact: Contact, attrs?: ContactAttributes): Promise<void>
224
225Updates a contact based on the specified contact information and attributes. This API uses a promise to return the result.
226
227**Permission required**: ohos.permission.WRITE_CONTACTS
228
229**System capability**: SystemCapability.Applications.ContactsData
230
231**Parameters**
232
233| Name | Type                                   | Mandatory| Description              |
234| ------- | --------------------------------------- | ---- | ------------------ |
235| contact | [Contact](#contact)                     | Yes  | Contact information.      |
236| attrs   | [ContactAttributes](#contactattributes) | No  | List of contact attributes.|
237
238**Return Value**
239| Type               | Description                                             |
240| ------------------- | ------------------------------------------------- |
241| Promise<void> | Promise used to return the result.|
242
243**Example**
244
245  ```js
246  let promise = contact.updateContact({
247      id: 1,
248      name: {fullName: 'xxx'},
249      phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
250  }, {
251      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
252  });
253  promise.then(() => {
254      console.log('updateContact success');
255  }).catch((err) => {
256      console.error(`updateContact fail: err->${JSON.stringify(err)}`);
257  });
258  ```
259
260
261## contact.isLocalContact
262
263isLocalContact(id: number, callback: AsyncCallback<boolean>): void
264
265Checks whether the ID of this contact is in the local address book. This API uses an asynchronous callback to return the result.
266
267**Permission required**: ohos.permission.READ_CONTACTS
268
269**System capability**: SystemCapability.Applications.ContactsData
270
271**Parameters**
272
273| Name  | Type                        | Mandatory| Description                                                        |
274| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
275| id       | number                       | Yes  | Contact ID. Each contact corresponds to one ID.                  |
276| callback | AsyncCallback<boolean> | Yes  | Callback used to return a boolean value. The value **true** indicates that the contact ID is in the local address book, and the value **false** indicates the opposite.|
277
278**Example**
279
280  ```js
281  contact.isLocalContact(/*id*/1, (err, data) => {
282      if (err) {
283          console.log(`isLocalContact callback: err->${JSON.stringify(err)}`);
284          return;
285      }
286      console.log(`isLocalContact callback: success data->${JSON.stringify(data)}`);
287  });
288  ```
289
290
291## contact.isLocalContact
292
293isLocalContact(id: number): Promise<boolean>
294
295Checks whether the ID of this contact is in the local address book. This API uses a promise to return the result.
296
297**Permission required**: ohos.permission.READ_CONTACTS
298
299**System capability**: SystemCapability.Applications.ContactsData
300
301**Parameters**
302
303| Name| Type  | Mandatory| Description                                      |
304| ------ | ------ | ---- | ------------------------------------------ |
305| id     | number | Yes  | Contact ID. Each contact corresponds to one ID.|
306
307**Return Value**
308
309| Type                  | Description                                                        |
310| ---------------------- | ------------------------------------------------------------ |
311| Promise<boolean> | 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.|
312
313**Example**
314
315  ```js
316  let promise = contact.isLocalContact(/*id*/1);
317  promise.then((data) => {
318      console.log(`isLocalContact success: data->${JSON.stringify(data)}`);
319  }).catch((err) => {
320      console.error(`isLocalContact fail: err->${JSON.stringify(err)}`);
321  });
322  ```
323
324
325## contact.isMyCard
326
327isMyCard(id: number, callback: AsyncCallback<boolean>): void
328
329Checks whether a contact is included in my card. This API uses an asynchronous callback to return the result.
330
331**Permission required**: ohos.permission.READ_CONTACTS
332
333**System capability**: SystemCapability.Applications.ContactsData
334
335**Parameters**
336
337| Name  | Type                        | Mandatory| Description                                                        |
338| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
339| id       | number                       | Yes  | Contact ID.                                        |
340| callback | AsyncCallback<boolean> | 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.|
341
342**Example**
343
344  ```js
345  contact.isMyCard(/*id*/1, (err, data) => {
346      if (err) {
347          console.log(`isMyCard callback: err->${JSON.stringify(err)}`);
348          return;
349      }
350      console.log(`isMyCard callback: success data->${JSON.stringify(data)}`);
351  });
352  ```
353
354
355## contact.isMyCard
356
357isMyCard(id: number): Promise<boolean>
358
359Checks whether a contact is included in my card. This API uses a promise to return the result.
360
361**Permission required**: ohos.permission.READ_CONTACTS
362
363**System capability**: SystemCapability.Applications.ContactsData
364
365**Parameters**
366
367| Name| Type  | Mandatory| Description                |
368| ------ | ------ | ---- | -------------------- |
369| id     | number | Yes  | Contact ID.|
370
371**Return Value**
372
373| Type                  | Description                                                        |
374| ---------------------- | ------------------------------------------------------------ |
375| Promise<boolean> | 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.|
376
377**Example**
378
379  ```js
380  let promise = contact.isMyCard(/*id*/1);
381  promise.then((data) => {
382      console.log(`isMyCard success: data->${JSON.stringify(data)}`);
383  }).catch((err) => {
384      console.error(`isMyCard fail: err->${JSON.stringify(err)}`);
385  });
386  ```
387
388
389## contact.queryMyCard
390
391queryMyCard(callback: AsyncCallback<Contact>): void
392
393Queries my card. This API uses an asynchronous callback to return the result.
394
395**Permission required**: ohos.permission.READ_CONTACTS
396
397**System capability**: SystemCapability.Applications.ContactsData
398
399**Parameters**
400
401| Name  | Type                                    | Mandatory| Description                          |
402| -------- | ---------------------------------------- | ---- | ------------------------------ |
403| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.|
404
405**Example**
406
407  ```js
408  contact.queryMyCard((err, data) => {
409      if (err) {
410          console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
411          return;
412      }
413      console.log(`queryMyCard callback: success data->${JSON.stringify(data)}`);
414  });
415  ```
416
417
418## contact.queryMyCard
419
420queryMyCard(attrs: ContactAttributes, callback: AsyncCallback<Contact>): void
421
422Queries my card. This API uses an asynchronous callback to return the result.
423
424**Permission required**: ohos.permission.READ_CONTACTS
425
426**System capability**: SystemCapability.Applications.ContactsData
427
428**Parameters**
429
430| Name  | Type                                    | Mandatory| Description                          |
431| -------- | ---------------------------------------- | ---- | ------------------------------ |
432| attrs    | [ContactAttributes](#contactattributes)  | Yes  | List of contact attributes.            |
433| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.|
434
435**Example**
436
437  ```js
438  contact.queryMyCard({
439      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
440  }, (err, data) => {
441      if (err) {
442          console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
443          return;
444      }
445      console.log(`queryMyCard callback: success data->${JSON.stringify(data)}`);
446  });
447  ```
448
449
450## contact.queryMyCard
451
452queryMyCard(attrs?: ContactAttributes): Promise<Contact>
453
454Queries my card based on the specified contact attributes. This API uses a promise to return the result.
455
456**Permission required**: ohos.permission.READ_CONTACTS
457
458**System capability**: SystemCapability.Applications.ContactsData
459
460**Parameters**
461
462| Name| Type                                   | Mandatory| Description              |
463| ------ | --------------------------------------- | ---- | ------------------ |
464| attrs  | [ContactAttributes](#contactattributes) | No  | List of contact attributes.|
465
466**Return Value**
467| Type                              | Description                                       |
468| ---------------------------------- | ------------------------------------------- |
469| Promise<[Contact](#contact)> | Promise used to return the result.|
470
471**Example**
472
473  ```js
474  let promise = contact.queryMyCard({
475      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
476  });
477  promise.then((data) => {
478      console.log(`queryMyCard success: data->${JSON.stringify(data)}`);
479  }).catch((err) => {
480      console.error(`queryMyCard fail: err->${JSON.stringify(err)}`);
481  });
482  ```
483
484
485## contact.selectContact
486
487selectContact(callback: AsyncCallback<Array<Contact>>): void
488
489Selects a contact. This API uses an asynchronous callback to return the result.
490
491**System capability**: SystemCapability.Applications.Contacts
492
493**Parameters**
494
495| Name  | Type                                                 | Mandatory| Description                                |
496| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
497| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
498
499**Example**
500
501  ```js
502  contact.selectContact((err, data) => {
503      if (err) {
504          console.log(`selectContact callback: err->${JSON.stringify(err)}`);
505          return;
506      }
507      console.log(`selectContact callback: success data->${JSON.stringify(data)}`);
508  });
509  ```
510
511
512## contact.selectContact
513
514selectContact(): Promise<Array<Contact>>
515
516Selects a contact. This API uses a promise to return the result.
517
518**System capability**: SystemCapability.Applications.Contacts
519
520**Return Value**
521
522| Type                                           | Description                                             |
523| ----------------------------------------------- | ------------------------------------------------- |
524| Promise<Array<[Contact](#contact)>> | Promise used to return the result.|
525
526**Example**
527
528  ```js
529  let promise = contact.selectContact();
530  promise.then((data) => {
531      console.log(`selectContact success: data->${JSON.stringify(data)}`);
532  }).catch((err) => {
533      console.error(`selectContact fail: err->${JSON.stringify(err)}`);
534  });
535  ```
536
537
538## contact.queryContact
539
540queryContact(key: string,  callback: AsyncCallback<Contact>): void
541
542Queries a contact based on the specified key. This API uses an asynchronous callback to return the result.
543
544**Permission required**: ohos.permission.READ_CONTACTS
545
546**System capability**: SystemCapability.Applications.ContactsData
547
548**Parameters**
549
550| Name  | Type                                    | Mandatory| Description                                  |
551| -------- | ---------------------------------------- | ---- | -------------------------------------- |
552| key      | string                                   | Yes  | Contact key. Each contact corresponds to one key.|
553| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.      |
554
555**Example**
556
557  ```js
558  contact.queryContact('xxx', (err, data) => {
559      if (err) {
560          console.log(`queryContact callback: err->${JSON.stringify(err)}`);
561          return;
562      }
563      console.log(`queryContact callback: success data->${JSON.stringify(data)}`);
564  });
565  ```
566
567
568## contact.queryContact
569
570queryContact(key: string, holder: Holder, callback: AsyncCallback<Contact>): void
571
572Queries a contact based on the specified key. This API uses an asynchronous callback to return the result.
573
574**Permission required**: ohos.permission.READ_CONTACTS
575
576**System capability**: SystemCapability.Applications.ContactsData
577
578**Parameters**
579
580| Name  | Type                                    | Mandatory| Description                                  |
581| -------- | ---------------------------------------- | ---- | -------------------------------------- |
582| key      | string                                   | Yes  | Contact key. Each contact corresponds to one key.|
583| holder   | [Holder](#holder)                        | Yes  | Application that creates the contacts.                |
584| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.      |
585
586**Example**
587
588  ```js
589  contact.queryContact('xxx', {
590      holderId: 0,
591      bundleName: "",
592      displayName: ""
593  }, (err, data) => {
594      if (err) {
595          console.log(`queryContact callback: err->${JSON.stringify(err)}`);
596          return;
597      }
598      console.log(`queryContact callback: success data->${JSON.stringify(data)}`);
599  });
600  ```
601
602
603## contact.queryContact
604
605queryContact(key: string,  attrs: ContactAttributes, callback: AsyncCallback<Contact>): void
606
607Queries a contact based on the specified key. This API uses an asynchronous callback to return the result.
608
609**Permission required**: ohos.permission.READ_CONTACTS
610
611**System capability**: SystemCapability.Applications.ContactsData
612
613**Parameters**
614
615| Name  | Type                                    | Mandatory| Description                                  |
616| -------- | ---------------------------------------- | ---- | -------------------------------------- |
617| key      | string                                   | Yes  | Contact key. Each contact corresponds to one key.|
618| attrs    | [ContactAttributes](#contactattributes)  | Yes  | List of contact attributes.                    |
619| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.      |
620
621**Example**
622
623  ```js
624  contact.queryContact('xxx', {
625      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
626  }, (err, data) => {
627      if (err) {
628          console.log(`queryContact callback: err->${JSON.stringify(err)}`);
629          return;
630      }
631      console.log(`queryContact callback: success data->${JSON.stringify(data)}`);
632  });
633  ```
634
635
636## contact.queryContact
637
638queryContact(key: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Contact>): void
639
640Queries a contact based on the specified key. This API uses an asynchronous callback to return the result.
641
642**Permission required**: ohos.permission.READ_CONTACTS
643
644**System capability**: SystemCapability.Applications.ContactsData
645
646**Parameters**
647
648| Name  | Type                                    | Mandatory| Description                                  |
649| -------- | ---------------------------------------- | ---- | -------------------------------------- |
650| key      | string                                   | Yes  | Contact key. Each contact corresponds to one key.|
651| holder   | [Holder](#holder)                        | Yes  | Application that creates the contacts.                |
652| attrs    | [ContactAttributes](#contactattributes)  | Yes  | List of contact attributes.                    |
653| callback | AsyncCallback<[Contact](#contact)> | Yes  | Callback used to return the result.      |
654
655**Example**
656
657  ```js
658  contact.queryContact('xxx', {
659      holderId: 0,
660      bundleName: "",
661      displayName: ""
662  }, {
663      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
664  }, (err, data) => {
665      if (err) {
666          console.log(`queryContact callback: err->${JSON.stringify(err)}`);
667          return;
668      }
669      console.log(`queryContact callback: success data->${JSON.stringify(data)}`);
670  });
671  ```
672
673
674## contact.queryContact
675
676queryContact(key: string, holder?: Holder, attrs?: ContactAttributes): Promise<Contact>
677
678Queries contacts based on the specified key, application, and attributes. This API uses a promise to return the result.
679
680**Permission required**: ohos.permission.READ_CONTACTS
681
682**System capability**: SystemCapability.Applications.ContactsData
683
684**Parameters**
685
686| Name| Type                                   | Mandatory| Description                                  |
687| ------ | --------------------------------------- | ---- | -------------------------------------- |
688| key    | string                                  | Yes  | Contact key. Each contact corresponds to one key.|
689| holder | [Holder](#holder)                       | No  | Application that creates the contacts.                |
690| attrs  | [ContactAttributes](#contactattributes) | No  | List of contact attributes.                    |
691
692**Return Value**
693| Type                              | Description                                           |
694| ---------------------------------- | ----------------------------------------------- |
695| Promise<[Contact](#contact)> | Promise used to return the result.|
696
697**Example**
698
699  ```js
700  let promise = contact.queryContact('xxx', {
701      holderId: 0,
702      bundleName: "",
703      displayName: ""
704  }, {
705      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
706  });
707  promise.then((data) => {
708      console.log(`queryContact success: data->${JSON.stringify(data)}`);
709  }).catch((err) => {
710      console.error(`queryContact fail: err->${JSON.stringify(err)}`);
711  });
712  ```
713
714
715## contact.queryContacts
716
717queryContacts(callback: AsyncCallback<Array<Contact>>): void
718
719Queries all contacts. This API uses an asynchronous callback to return the result.
720
721**Permission required**: ohos.permission.READ_CONTACTS
722
723**System capability**: SystemCapability.Applications.ContactsData
724
725**Parameters**
726
727| Name  | Type                                                 | Mandatory| Description                                  |
728| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
729| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
730
731**Example**
732
733  ```js
734  contact.queryContacts((err, data) => {
735      if (err) {
736          console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
737          return;
738      }
739      console.log(`queryContacts callback: success data->${JSON.stringify(data)}`);
740  });
741  ```
742
743
744## contact.queryContacts
745
746queryContacts(holder: Holder, callback: AsyncCallback<Array<Contact>>): void
747
748Queries all contacts. This API uses an asynchronous callback to return the result.
749
750**Permission required**: ohos.permission.READ_CONTACTS
751
752**System capability**: SystemCapability.Applications.ContactsData
753
754**Parameters**
755
756| Name  | Type                                                 | Mandatory| Description                                  |
757| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
758| holder   | [Holder](#holder)                                     | Yes  | Application that creates the contacts.                |
759| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
760
761**Example**
762
763  ```js
764  contact.queryContacts({
765      holderId: 0,
766      bundleName: "",
767      displayName: ""
768  }, (err, data) => {
769      if (err) {
770          console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
771          return;
772      }
773      console.log(`queryContacts callback: success data->${JSON.stringify(data)}`);
774  });
775  ```
776
777
778## contact.queryContacts
779
780queryContacts(attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
781
782Queries all contacts. This API uses an asynchronous callback to return the result.
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| attrs    | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                    |
793| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
794
795**Example**
796
797  ```js
798  contact.queryContacts({
799      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
800  }, (err, data) => {
801      if (err) {
802          console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
803          return;
804      }
805      console.log(`queryContacts callback: success data->${JSON.stringify(data)}`);
806  });
807  ```
808
809
810## contact.queryContacts
811
812queryContacts(holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
813
814Queries all contacts. This API uses an asynchronous callback to return the result.
815
816**Permission required**: ohos.permission.READ_CONTACTS
817
818**System capability**: SystemCapability.Applications.ContactsData
819
820**Parameters**
821
822| Name  | Type                                                 | Mandatory| Description                                  |
823| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
824| holder   | [Holder](#holder)                                     | Yes  | Application that creates the contacts.                |
825| attrs    | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                    |
826| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
827
828**Example**
829
830  ```js
831  contact.queryContacts({
832      holderId: 0,
833      bundleName: "",
834      displayName: ""
835  }, {
836      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
837  }, (err, data) => {
838      if (err) {
839          console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
840          return;
841      }
842      console.log(`queryContacts callback: success data->${JSON.stringify(data)}`);
843  });
844  ```
845
846
847## contact.queryContacts
848
849queryContacts(holder?: Holder, attrs?: ContactAttributes): Promise<Array<Contact>>
850
851Queries all contacts based on the specified application and attributes. This API uses a promise to return the result.
852
853**Permission required**: ohos.permission.READ_CONTACTS
854
855**System capability**: SystemCapability.Applications.ContactsData
856
857**Parameters**
858
859| Name| Type                                   | Mandatory| Description                  |
860| ------ | --------------------------------------- | ---- | ---------------------- |
861| holder | [Holder](#holder)                       | No  | Application that creates the contacts.|
862| attrs  | [ContactAttributes](#contactattributes) | No  | List of contact attributes.    |
863
864**Return Value**
865| Type                                           | Description                                               |
866| ----------------------------------------------- | --------------------------------------------------- |
867| Promise<Array<[Contact](#contact)>> | Promise used to return the result.|
868
869**Example**
870
871  ```js
872  let promise = contact.queryContacts({
873      holderId: 0,
874      bundleName: "",
875      displayName: ""
876  }, {
877      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
878  });
879  promise.then((data) => {
880      console.log(`queryContacts success: data->${JSON.stringify(data)}`);
881  }).catch((err) => {
882      console.error(`queryContacts fail: err->${JSON.stringify(err)}`);
883  });
884  ```
885
886
887## contact.queryContactsByPhoneNumber
888
889queryContactsByPhoneNumber(phoneNumber: string, callback: AsyncCallback<Array<Contact>>): void
890
891Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result.
892
893**Permission required**: ohos.permission.READ_CONTACTS
894
895**System capability**: SystemCapability.Applications.ContactsData
896
897**Parameters**
898
899| Name     | Type                                                 | Mandatory| Description                                  |
900| ----------- | ----------------------------------------------------- | ---- | -------------------------------------- |
901| phoneNumber | string                                                | Yes  | Phone number of the contacts.                    |
902| callback    | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
903
904**Example**
905
906  ```js
907  contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => {
908      if (err) {
909          console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
910          return;
911      }
912      console.log(`queryContactsByPhoneNumber callback: success data->${JSON.stringify(data)}`);
913  });
914  ```
915
916
917## contact.queryContactsByPhoneNumber
918
919queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, callback: AsyncCallback<Array<Contact>>): void
920
921Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result.
922
923**Permission required**: ohos.permission.READ_CONTACTS
924
925**System capability**: SystemCapability.Applications.ContactsData
926
927**Parameters**
928
929| Name     | Type                                                 | Mandatory| Description                                  |
930| ----------- | ----------------------------------------------------- | ---- | -------------------------------------- |
931| phoneNumber | string                                                | Yes  | Phone number of the contacts.                    |
932| holder      | [Holder](#holder)                                     | Yes  | Application that creates the contacts.                |
933| callback    | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
934
935**Example**
936
937  ```js
938  contact.queryContactsByPhoneNumber('138xxxxxxxx', {
939      holderId: 0,
940      bundleName: "",
941      displayName: ""
942  }, (err, data) => {
943      if (err) {
944          console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
945          return;
946      }
947      console.log(`queryContactsByPhoneNumber callback: success data->${JSON.stringify(data)}`);
948  });
949  ```
950
951
952## contact.queryContactsByPhoneNumber
953
954queryContactsByPhoneNumber(phoneNumber: string, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
955
956Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result.
957
958**Permission required**: ohos.permission.READ_CONTACTS
959
960**System capability**: SystemCapability.Applications.ContactsData
961
962**Parameters**
963
964| Name     | Type                                                 | Mandatory| Description                                  |
965| ----------- | ----------------------------------------------------- | ---- | -------------------------------------- |
966| phoneNumber | string                                                | Yes  | Phone number of the contacts.                    |
967| attrs       | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                    |
968| callback    | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
969
970**Example**
971
972  ```js
973  contact.queryContactsByPhoneNumber('138xxxxxxxx', {
974      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
975  }, (err, data) => {
976      if (err) {
977          console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
978          return;
979      }
980      console.log(`queryContactsByPhoneNumber callback: success data->${JSON.stringify(data)}`);
981  });
982  ```
983
984
985## contact.queryContactsByPhoneNumber
986
987queryContactsByPhoneNumber(phoneNumber: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
988
989Queries contacts based on the specified phone number. This API uses an asynchronous callback to return the result.
990
991**Permission required**: ohos.permission.READ_CONTACTS
992
993**System capability**: SystemCapability.Applications.ContactsData
994
995**Parameters**
996
997| Name     | Type                                                 | Mandatory| Description                                  |
998| ----------- | ----------------------------------------------------- | ---- | -------------------------------------- |
999| phoneNumber | string                                                | Yes  | Phone number of the contacts.                    |
1000| holder      | [Holder](#holder)                                     | Yes  | Application that creates the contacts.                |
1001| attrs       | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                    |
1002| callback    | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
1003
1004**Example**
1005
1006  ```js
1007  contact.queryContactsByPhoneNumber('138xxxxxxxx', {
1008      holderId: 0,
1009      bundleName: "",
1010      displayName: ""
1011  }, {
1012      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
1013  }, (err, data) => {
1014      if (err) {
1015          console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
1016          return;
1017      }
1018      console.log(`queryContactsByPhoneNumber callback: success data->${JSON.stringify(data)}`);
1019  });
1020  ```
1021
1022
1023## contact.queryContactsByPhoneNumber
1024
1025queryContactsByPhoneNumber(phoneNumber: string, holder?: Holder, attrs?: ContactAttributes): Promise<Array<Contact>>
1026
1027Queries contacts based on the specified phone number, application, and attributes. This API uses a promise to return the result.
1028
1029**Permission required**: ohos.permission.READ_CONTACTS
1030
1031**System capability**: SystemCapability.Applications.ContactsData
1032
1033**Parameters**
1034
1035| Name     | Type                                   | Mandatory| Description                  |
1036| ----------- | --------------------------------------- | ---- | ---------------------- |
1037| phoneNumber | string                                  | Yes  | Phone number of the contacts.    |
1038| holder      | [Holder](#holder)                       | No  | Application that creates the contacts.|
1039| attrs       | [ContactAttributes](#contactattributes) | No  | List of contact attributes.    |
1040
1041**Return Value**
1042
1043| Type                                           | Description                                               |
1044| ----------------------------------------------- | --------------------------------------------------- |
1045| Promise<Array<[Contact](#contact)>> | Promise used to return the result.|
1046
1047**Example**
1048
1049  ```js
1050  let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
1051      holderId: 0,
1052      bundleName: "",
1053      displayName: ""
1054  }, {
1055      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
1056  });
1057  promise.then((data) => {
1058      console.log(`queryContactsByPhoneNumber success: data->${JSON.stringify(data)}`);
1059  }).catch((err) => {
1060      console.error(`queryContactsByPhoneNumber fail: err->${JSON.stringify(err)}`);
1061  });
1062  ```
1063
1064
1065## contact.queryContactsByEmail
1066
1067queryContactsByEmail(email: string, callback: AsyncCallback<Array<Contact>>): void
1068
1069Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result.
1070
1071**Permission required**: ohos.permission.READ_CONTACTS
1072
1073**System capability**: SystemCapability.Applications.ContactsData
1074
1075**Parameters**
1076
1077| Name  | Type                                                 | Mandatory| Description                                  |
1078| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
1079| email    | string                                                | Yes  | Email address of the contact.                    |
1080| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
1081
1082**Example**
1083
1084  ```js
1085  contact.queryContactsByEmail('xxx@email.com', (err, data) => {
1086      if (err) {
1087          console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
1088          return;
1089      }
1090      console.log(`queryContactsByEmail callback: success data->${JSON.stringify(data)}`);
1091  });
1092  ```
1093
1094
1095## contact.queryContactsByEmail
1096
1097queryContactsByEmail(email: string, holder: Holder, callback: AsyncCallback<Array<Contact>>): void
1098
1099Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result.
1100
1101**Permission required**: ohos.permission.READ_CONTACTS
1102
1103**System capability**: SystemCapability.Applications.ContactsData
1104
1105**Parameters**
1106
1107| Name  | Type                                                 | Mandatory| Description                                  |
1108| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
1109| email    | string                                                | Yes  | Email address of the contact.                    |
1110| holder   | [Holder](#holder)                                     | Yes  | Application that creates the contacts.                |
1111| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
1112
1113**Example**
1114
1115  ```js
1116  contact.queryContactsByEmail('xxx@email.com', {
1117      holderId: 0,
1118      bundleName: "",
1119      displayName: ""
1120  }, (err, data) => {
1121      if (err) {
1122          console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
1123          return;
1124      }
1125      console.log(`queryContactsByEmail callback: success data->${JSON.stringify(data)}`);
1126  });
1127  ```
1128
1129
1130## contact.queryContactsByEmail
1131
1132queryContactsByEmail(email: string, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
1133
1134Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result.
1135
1136**Permission required**: ohos.permission.READ_CONTACTS
1137
1138**System capability**: SystemCapability.Applications.ContactsData
1139
1140**Parameters**
1141
1142| Name  | Type                                                 | Mandatory| Description                                |
1143| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
1144| email    | string                                                | Yes  | Email address of the contact.                  |
1145| attrs    | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                  |
1146| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
1147
1148**Example**
1149
1150  ```js
1151  contact.queryContactsByEmail('xxx@email.com', {
1152      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
1153  }, (err, data) => {
1154      if (err) {
1155          console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
1156          return;
1157      }
1158      console.log(`queryContactsByEmail callback: success data->${JSON.stringify(data)}`);
1159  });
1160  ```
1161
1162
1163## contact.queryContactsByEmail
1164
1165queryContactsByEmail(email: string, holder: Holder, attrs: ContactAttributes, callback: AsyncCallback<Array<Contact>>): void
1166
1167Queries contacts based on the specified email address. This API uses an asynchronous callback to return the result.
1168
1169**Permission required**: ohos.permission.READ_CONTACTS
1170
1171**System capability**: SystemCapability.Applications.ContactsData
1172
1173**Parameters**
1174
1175| Name  | Type                                                 | Mandatory| Description                                |
1176| -------- | ----------------------------------------------------- | ---- | ------------------------------------ |
1177| email    | string                                                | Yes  | Email address of the contact.                  |
1178| holder   | [Holder](#holder)                                     | Yes  | Application that creates the contacts.              |
1179| attrs    | [ContactAttributes](#contactattributes)               | Yes  | List of contact attributes.                  |
1180| callback | AsyncCallback<Array<[Contact](#contact)>> | Yes  | Callback used to return the result.|
1181
1182**Example**
1183
1184  ```js
1185  contact.queryContactsByEmail('xxx@email.com', {
1186      holderId: 0,
1187      bundleName: "",
1188      displayName: ""
1189  }, {
1190      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
1191  }, (err, data) => {
1192      if (err) {
1193          console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
1194          return;
1195      }
1196      console.log(`queryContactsByEmail callback: success data->${JSON.stringify(data)}`);
1197  });
1198  ```
1199
1200
1201## contact.queryContactsByEmail
1202
1203queryContactsByEmail(email: string, holder?: Holder, attrs?: ContactAttributes): Promise<Array<Contact>>
1204
1205Queries contacts based on the specified email address, application, and attributes. This API uses a promise to return the result.
1206
1207**Permission required**: ohos.permission.READ_CONTACTS
1208
1209**System capability**: SystemCapability.Applications.ContactsData
1210
1211**Parameters**
1212
1213| Name| Type                                   | Mandatory| Description                  |
1214| ------ | --------------------------------------- | ---- | ---------------------- |
1215| email  | string                                  | Yes  | Email address of the contact.    |
1216| holder | [Holder](#holder)                       | No  | Application that creates the contacts.|
1217| attrs  | [ContactAttributes](#contactattributes) | No  | List of contact attributes.    |
1218
1219**Return Value**
1220
1221| Type                                           | Description                                               |
1222| ----------------------------------------------- | --------------------------------------------------- |
1223| Promise<Array<[Contact](#contact)>> | Promise used to return the result.|
1224
1225**Example**
1226
1227  ```js
1228  let promise = contact.queryContactsByEmail('xxx@email.com', {
1229      holderId: 0,
1230      bundleName: "",
1231      displayName: ""
1232  }, {
1233      attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
1234  });
1235  promise.then((data) => {
1236      console.log(`queryContactsByEmail success: data->${JSON.stringify(data)}`);
1237  }).catch((err) => {
1238      console.error(`queryContactsByEmail fail: err->${JSON.stringify(err)}`);
1239  });
1240  ```
1241
1242
1243## contact.queryGroups
1244
1245queryGroups(callback: AsyncCallback<Array<Group>>): void
1246
1247Queries all groups of this contact. This API uses an asynchronous callback to return the result.
1248
1249**Permission required**: ohos.permission.READ_CONTACTS
1250
1251**System capability**: SystemCapability.Applications.ContactsData
1252
1253**Parameters**
1254
1255| Name  | Type                                             | Mandatory| Description                                |
1256| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
1257| callback | AsyncCallback<Array<[Group](#group)>> | Yes  | Callback used to return the result.|
1258
1259**Example**
1260
1261  ```js
1262  contact.queryGroups((err, data) => {
1263      if (err) {
1264          console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
1265          return;
1266      }
1267      console.log(`queryGroups callback: success data->${JSON.stringify(data)}`);
1268  });
1269  ```
1270
1271
1272## contact.queryGroups
1273
1274queryGroups(holder: Holder, callback: AsyncCallback<Array<Group>>): void
1275
1276Queries all groups of this contact. This API uses an asynchronous callback to return the result.
1277
1278**Permission required**: ohos.permission.READ_CONTACTS
1279
1280**System capability**: SystemCapability.Applications.ContactsData
1281
1282**Parameters**
1283
1284| Name  | Type                                             | Mandatory| Description                                |
1285| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
1286| holder   | Holder                                            | Yes  | Application that creates the contacts.              |
1287| callback | AsyncCallback<Array<[Group](#group)>> | Yes  | Callback used to return the result.|
1288
1289**Example**
1290
1291  ```js
1292  contact.queryGroups({
1293      holderId: 0,
1294      bundleName: "",
1295      displayName: ""
1296  }, (err, data) => {
1297      if (err) {
1298          console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
1299          return;
1300      }
1301      console.log(`queryGroups callback: success data->${JSON.stringify(data)}`);
1302  });
1303  ```
1304
1305
1306## contact.queryGroups
1307
1308queryGroups(holder?: Holder): Promise<Array<Group>>
1309
1310Queries all groups of this contact based on the specified application. This API uses a promise to return the result.
1311
1312**Permission required**: ohos.permission.READ_CONTACTS
1313
1314**System capability**: SystemCapability.Applications.ContactsData
1315
1316**Parameters**
1317
1318| Name| Type             | Mandatory| Description                  |
1319| ------ | ----------------- | ---- | ---------------------- |
1320| holder | [Holder](#holder) | No  | Application that creates the contacts.|
1321
1322**Return Value**
1323
1324| Type                                       | Description                                             |
1325| ------------------------------------------- | ------------------------------------------------- |
1326| Promise<Array<[Group](#group)>> | Promise used to return the result.|
1327
1328**Example**
1329
1330  ```js
1331  let promise = contact.queryGroups({
1332      holderId: 0,
1333      bundleName: "",
1334      displayName: ""
1335  });
1336  promise.then((data) => {
1337      console.log(`queryGroups success: data->${JSON.stringify(data)}`);
1338  }).catch((err) => {
1339      console.error(`queryGroups fail: err->${JSON.stringify(err)}`);
1340  });
1341  ```
1342
1343
1344## contact.queryHolders
1345
1346queryHolders(callback: AsyncCallback<Array<Holder>>): void
1347
1348Queries all applications that have created contacts. This API uses an asynchronous callback to return the result.
1349
1350**Permission required**: ohos.permission.READ_CONTACTS
1351
1352**System capability**: SystemCapability.Applications.ContactsData
1353
1354**Parameters**
1355
1356| Name  | Type                                               | Mandatory| Description                                                |
1357| -------- | --------------------------------------------------- | ---- | ---------------------------------------------------- |
1358| callback | AsyncCallback<Array<[Holder](#holder)>> | Yes  | Callback used to return the result.|
1359
1360**Example**
1361
1362  ```js
1363  contact.queryHolders((err, data) => {
1364      if (err) {
1365          console.log(`queryHolders callback: err->${JSON.stringify(err)}`);
1366          return;
1367      }
1368      console.log(`queryHolders callback: success data->${JSON.stringify(data)}`);
1369  });
1370  ```
1371
1372
1373## contact.queryHolders
1374
1375queryHolders(): Promise<Array<Holder>>
1376
1377Queries all applications that have created contacts. This API uses a promise to return the result.
1378
1379**Permission required**: ohos.permission.READ_CONTACTS
1380
1381**System capability**: SystemCapability.Applications.ContactsData
1382
1383**Return Value**
1384
1385| Type                                         | Description                                                        |
1386| --------------------------------------------- | ------------------------------------------------------------ |
1387| Promise<Array<[Holder](#holder)>> | Promise used to return the result.|
1388
1389**Example**
1390
1391  ```js
1392  let promise = contact.queryHolders();
1393  promise.then((data) => {
1394      console.log(`queryHolders success: data->${JSON.stringify(data)}`);
1395  }).catch((err) => {
1396      console.error(`queryHolders fail: err->${JSON.stringify(err)}`);
1397  });
1398  ```
1399
1400
1401## contact.queryKey
1402
1403queryKey(id: number, callback: AsyncCallback<string>): void
1404
1405Queries the key of a contact based on the specified contact ID. This API uses an asynchronous callback to return the result.
1406
1407**Permission required**: ohos.permission.READ_CONTACTS
1408
1409**System capability**: SystemCapability.Applications.ContactsData
1410
1411**Parameters**
1412
1413| Name  | Type                       | Mandatory| Description                                   |
1414| -------- | --------------------------- | ---- | --------------------------------------- |
1415| id       | number                      | Yes  | Contact ID.                   |
1416| callback | AsyncCallback<string> | Yes  | Callback used to return the result.|
1417
1418**Example**
1419
1420  ```js
1421  contact.queryKey(/*id*/1, (err, data) => {
1422      if (err) {
1423          console.log(`queryKey callback: err->${JSON.stringify(err)}`);
1424          return;
1425      }
1426      console.log(`queryKey callback: success data->${JSON.stringify(data)}`);
1427  });
1428  ```
1429
1430
1431## contact.queryKey
1432
1433queryKey(id: number, holder: Holder, callback: AsyncCallback<string>): void
1434
1435Queries the key of a contact based on the specified contact ID. This API uses an asynchronous callback to return the result.
1436
1437**Permission required**: ohos.permission.READ_CONTACTS
1438
1439**System capability**: SystemCapability.Applications.ContactsData
1440
1441**Parameters**
1442
1443| Name  | Type                       | Mandatory| Description                                   |
1444| -------- | --------------------------- | ---- | --------------------------------------- |
1445| id       | number                      | Yes  | Contact ID.                   |
1446| holder   | [Holder](#holder)           | Yes  | Application that creates the contacts.                 |
1447| callback | AsyncCallback<string> | Yes  | Callback used to return the result.|
1448
1449**Example**
1450
1451  ```js
1452  contact.queryKey(/*id*/1, {
1453      holderId: 0,
1454      bundleName: "",
1455      displayName: ""
1456  }, (err, data) => {
1457      if (err) {
1458          console.log(`queryKey callback: err->${JSON.stringify(err)}`);
1459          return;
1460      }
1461      console.log(`queryKey callback: success data->${JSON.stringify(data)}`);
1462  });
1463  ```
1464
1465
1466## contact.queryKey
1467
1468queryKey(id: number, holder?: Holder): Promise<string>
1469
1470Queries the key of a contact based on the specified contact ID and application. This API uses a promise to return the result.
1471
1472**Permission required**: ohos.permission.READ_CONTACTS
1473
1474**System capability**: SystemCapability.Applications.ContactsData
1475
1476**Parameters**
1477
1478| Name| Type             | Mandatory| Description                  |
1479| ------ | ----------------- | ---- | ---------------------- |
1480| id     | number            | Yes  | Contact ID.  |
1481| holder | [Holder](#holder) | No  | Application that creates the contacts.|
1482
1483**Return Value**
1484
1485| Type                 | Description                                                |
1486| --------------------- | ---------------------------------------------------- |
1487| Promise<string> | Promise used to return the result.|
1488
1489**Example**
1490
1491  ```js
1492  let promise = contact.queryKey(/*id*/1, {
1493      holderId: 0,
1494      bundleName: "",
1495      displayName: ""
1496  });
1497  promise.then((data) => {
1498      console.log(`queryKey success: data->${JSON.stringify(data)}`);
1499  }).catch((err) => {
1500      console.error(`queryKey fail: err->${JSON.stringify(err)}`);
1501  });
1502  ```
1503
1504
1505## Contact
1506
1507Defines a contact.
1508
1509**System capability**: SystemCapability.Applications.ContactsData
1510
1511### Constant
1512
1513| Name              | Value  | Description            |
1514| ------------------ | ---- | ---------------- |
1515| INVALID_CONTACT_ID | -1   | Default contact ID.|
1516
1517
1518### Attributes
1519
1520|       Name       |                   Type                 | Readable| Writable| Description                                  |
1521| ----------------- | --------------------------------------- | ---- | ---- | -------------------------------------- |
1522| id                | number                                  | Yes  | No  | Contact ID.                          |
1523| key               | string                                  | Yes  | No  | Contact key.                         |
1524| contactAttributes | [ContactAttributes](#contactattributes) | Yes  | Yes  | List of contact attributes.                    |
1525| emails            | [Email](#email)[]                       | Yes  | Yes  | List of email addresses of the contact.                |
1526| events            | [Event](#event)[]                       | Yes  | Yes  | List of important dates such as birthdays and anniversaries of the contact.|
1527| groups            | [Group](#group)[]                       | Yes  | Yes  | List of groups of the contact.                    |
1528| imAddresses       | [ImAddress](#imaddress)[]               | Yes  | Yes  | List of instant message addresses of the contact.            |
1529| phoneNumbers      | [PhoneNumber](#phonenumber)[]           | Yes  | Yes  | List of phone numbers of the contact.                |
1530| portrait          | [Portrait](#portrait)                   | Yes  | Yes  | Contact portrait.                        |
1531| postalAddresses   | [PostalAddress](#postaladdress)[]       | Yes  | Yes  | List of postal addresses of the contact.                |
1532| relations         | [Relation](#relation)[]                 | Yes  | Yes  | List of relationships with the contact.                    |
1533| sipAddresses      | [SipAddress](#sipaddress)[]             | Yes  | Yes  | List of Session Initiation Protocol (SIP) addresses of the contact. |
1534| websites          | [Website](#website)[]                   | Yes  | Yes  | List of websites of the contact.                    |
1535| name              | [Name](#name)                           | Yes  | Yes  | Contact name.                        |
1536| nickName          | [NickName](#nickname)                   | Yes  | Yes  | Contact nickname.                        |
1537| note              | [Note](#note)                           | Yes  | Yes  | Contact notes.                        |
1538| organization      | [Organization](#organization)           | Yes  | Yes  | Organization of the contact.                    |
1539
1540
1541**Example**
1542
1543Create contact data in JSON format:
1544
1545
1546```js
1547let myContact = {
1548    phoneNumbers: [{
1549        phoneNumber: "138xxxxxxxx"
1550    }],
1551    name: {
1552        fullName: "fullName",
1553        namePrefix: "namePrefix"
1554    },
1555    nickName: {
1556        nickName: "nickName"
1557    }
1558};
1559```
1560
1561
1562  Or, create data by configuring a new Contact object.
1563
1564```js
1565let myContact = new contact.Contact();
1566let name = new contact.Name();
1567name.fullName = "fullName";
1568let phoneNumber = new contact.PhoneNumber();
1569phoneNumber.phoneNumber = "138xxxxxxxx";
1570myContact.name = name;
1571myContact.phoneNumbers = [phoneNumber];
1572```
1573
1574
1575## ContactAttributes
1576
1577Provides a list of contact attributes, which are generally used as arguments.
1578If **null** is passed, all attributes are queried by default.
1579
1580**System capability**: SystemCapability.Applications.ContactsData
1581
1582| Name      |            Type          | Readable| Writable| Description            |
1583| ---------- | ------------------------- | ---- | ---- | ---------------- |
1584| attributes | [Attribute](#attribute)[] | Yes  | Yes  | List of contact attributes.|
1585
1586
1587**Example**
1588
1589Create contact data in JSON format:
1590
1591
1592```js
1593let contactAttributes = {
1594    attributes: [
1595        contact.Attribute.ATTR_EMAIL,
1596        contact.Attribute.ATTR_NAME,
1597        contact.Attribute.ATTR_PHONE
1598    ]
1599};
1600```
1601
1602Or, create data by configuring a **ContactAttributes** object.
1603
1604
1605```js
1606let contactAttributes = new contact.ContactAttributes();
1607contactAttributes.attributes = [contact.Attribute.ATTR_EMAIL];
1608```
1609
1610
1611## Attribute
1612
1613Enumerates contact attributes.
1614
1615**System capability**: SystemCapability.Applications.ContactsData
1616
1617| Name                 | Description                              |
1618| --------------------- | ---------------------------------- |
1619| ATTR_CONTACT_EVENT    | Important dates such as birthday and anniversaries of the contact.|
1620| ATTR_EMAIL            | Email address of the contact.                |
1621| ATTR_GROUP_MEMBERSHIP | Groups of the contact.                    |
1622| ATTR_IM               | IM addresses of the contact.            |
1623| ATTR_NAME             | Contact name.                    |
1624| ATTR_NICKNAME         | Contact nickname.                    |
1625| ATTR_NOTE             | Contact notes.                    |
1626| ATTR_ORGANIZATION     | Organization of the contact.                |
1627| ATTR_PHONE            | Phone number of the contacts.                |
1628| ATTR_PORTRAIT         | Contact portrait.                    |
1629| ATTR_POSTAL_ADDRESS   | Postal address of the contact.                |
1630| ATTR_RELATION         | Relationship with the contact.                    |
1631| ATTR_SIP_ADDRESS      | SIP addresses of the contact. |
1632| ATTR_WEBSITE          | Website that stores the contact information.                    |
1633
1634
1635**Example**
1636
1637Create contact data in JSON format:
1638
1639```js
1640let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE];
1641```
1642
1643
1644## Email
1645
1646Defines a contact's email.
1647
1648**System capability**: SystemCapability.Applications.ContactsData
1649
1650### Constant
1651
1652| Name            | Value  | Description            |
1653| ---------------- | ---- | ---------------- |
1654| CUSTOM_LABEL     | 0    | Custom mailbox type.|
1655| EMAIL_HOME       | 1    | Home mailbox.  |
1656| EMAIL_WORK       | 2    | Work mailbox.  |
1657| EMAIL_OTHER      | 3    | Other mailbox.  |
1658| INVALID_LABEL_ID | -1   | Invalid mailbox.  |
1659
1660
1661### Attributes
1662
1663| Name       |   Type  | Readable| Writable| Description            |
1664| ----------- | -------- | ---- | ---- | ---------------- |
1665| email       | string   | Yes  | Yes  | Email addresses      |
1666| labelName   | string   | Yes  | Yes  | Name of the mailbox type.|
1667| displayName | string   | Yes  | Yes  | Displayed name of the mailbox.|
1668| labelId     | number   | Yes  | Yes  | Mailbox type.    |
1669
1670
1671**Example**
1672
1673  Create contact data in JSON format:
1674
1675```js
1676let email = {
1677    email: "xxx@email.com",
1678    displayName: "displayName"
1679}
1680```
1681
1682
1683  Or, create data by configuring an **Email** object.
1684
1685```js
1686let email = new contact.Email();
1687email.email = "xxx@email.com";
1688```
1689
1690
1691## Holder
1692
1693Defines an application that creates the contact.
1694
1695**System capability**: SystemCapability.Applications.ContactsData
1696
1697| Name       |   Type  | Readable| Writable| Description      |
1698| ----------- | -------- | ---- | ---- | ---------- |
1699| bundleName  | string   | Yes  | No  | Bundle name of an application.    |
1700| displayName | string   | Yes  | No  | Application name.|
1701| holderId    | number   | Yes  | Yes  | Application ID.  |
1702
1703
1704**Example**
1705
1706  Create contact data in JSON format:
1707
1708```js
1709let holder = {
1710  holderId: 0
1711};
1712```
1713
1714  Or, create data by configuring a **Holder** object.
1715
1716```js
1717let holder = new contact.Holder();
1718holder.holderId = 0;
1719```
1720
1721
1722## Event
1723
1724Defines a contact's event.
1725
1726**System capability**: SystemCapability.Applications.ContactsData
1727
1728### Constant
1729
1730| Name             | Value  | Description              |
1731| ----------------- | ---- | ------------------ |
1732| CUSTOM_LABEL      | 0    | Custom event.  |
1733| EVENT_ANNIVERSARY | 1    | Anniversary event.|
1734| EVENT_OTHER       | 2    | Other event.    |
1735| EVENT_BIRTHDAY    | 3    | Birthday event.    |
1736| INVALID_LABEL_ID  | -1   | Invalid event.    |
1737
1738
1739### Attributes
1740
1741|    Name  |   Type  | Readable| Writable| Description          |
1742| --------- | -------- | ---- | ---- | -------------- |
1743| eventDate | string   | Yes  | Yes  | Event date.  |
1744| labelName | string   | Yes  | Yes  | Event type.|
1745| labelId   | number   | Yes  | Yes  | Event type ID.    |
1746
1747
1748**Example**
1749
1750  Create contact data in JSON format:
1751
1752```js
1753let event = {
1754    eventDate: "xxxxxx"
1755};
1756```
1757
1758  Or, create data by configuring an **Event** object.
1759
1760```js
1761let event = new contact.Event();
1762event.eventDate = "xxxxxx";
1763```
1764
1765
1766## Group
1767
1768Defines a contact group.
1769
1770**System capability**: SystemCapability.Applications.ContactsData
1771
1772| Name   |   Type  | Readable| Writable| Description              |
1773| ------- | -------- | ---- | ---- | ------------------ |
1774| groupId | number   | Yes  | Yes  | ID of a contact group.  |
1775| title   | string   | Yes  | Yes  | Name of a contact group.|
1776
1777
1778**Example**
1779
1780  Create contact data in JSON format:
1781
1782```js
1783let group = {
1784    groupId: 1,
1785    title: "title"
1786};
1787```
1788
1789  Or, create data by configuring a **Group** object.
1790
1791```js
1792let group = new contact.Group();
1793group.title = "title";
1794```
1795
1796
1797## ImAddress
1798
1799Enumerates IM addresses.
1800
1801**System capability**: SystemCapability.Applications.ContactsData
1802
1803### Constant
1804
1805| Name            | Value  | Description                |
1806| ---------------- | ---- | -------------------- |
1807| CUSTOM_LABEL     | -1   | Custom IM|
1808| IM_AIM           | 0    | AIM   |
1809| IM_MSN           | 1    | MSN   |
1810| IM_YAHOO         | 2    | Yahoo |
1811| IM_SKYPE         | 3    | Skype |
1812| IM_QQ            | 4    | QQ    |
1813| IM_ICQ           | 6    | ICQ   |
1814| IM_JABBER        | 7    | JABBER|
1815| INVALID_LABEL_ID | -2   | Invalid IM|
1816
1817
1818### Attributes
1819
1820| Name     |   Type  | Readable| Writable| Description              |
1821| --------- | -------- | ---- | ---- | ------------------ |
1822| imAddress | string   | Yes  | Yes  | IM address.    |
1823| labelName | string   | Yes  | Yes  | IM name.|
1824| labelId   | number   | Yes  | Yes  | IM ID.    |
1825
1826
1827**Example**
1828
1829  Create contact data in JSON format:
1830
1831```js
1832let imAddress = {
1833    imAddress: "imAddress",
1834    labelName: "labelName"
1835};
1836```
1837
1838
1839  Or, create data by configuring an **ImAddress** object.
1840
1841```js
1842let imAddress = new contact.ImAddress();
1843imAddress.imAddress = "imAddress";
1844```
1845
1846
1847## Name
1848
1849Defines a contact's name.
1850
1851**System capability**: SystemCapability.Applications.ContactsData
1852
1853| Name              |   Type  | Readable| Writable| Description                       |
1854| ------------------ | -------- | ---- | ---- | --------------------------- |
1855| familyName         | string   | Yes  | Yes  | Family name.         |
1856| familyNamePhonetic | string   | Yes  | Yes  | Family name in pinyin.     |
1857| fullName           | string   | Yes  | Yes  | Full name of the contact.             |
1858| givenName          | string   | Yes  | Yes  | Given name of the contact.|
1859| givenNamePhonetic  | string   | Yes  | Yes  | Given name of the contact in pinyin.         |
1860| middleName         | string   | Yes  | Yes  | Middle name of the contact.           |
1861| middleNamePhonetic | string   | Yes  | Yes  | Middle name of the contact in pinyin.       |
1862| namePrefix         | string   | Yes  | Yes  | Prefix of the contact name.         |
1863| nameSuffix         | string   | Yes  | Yes  | Suffix of the contact name.         |
1864
1865
1866**Example**
1867
1868  Create contact data in JSON format:
1869
1870```js
1871let name = {
1872    familyName: "familyName",
1873    fullName: "fullName"
1874};
1875```
1876
1877  Or, create data by configuring a **Name** object.
1878
1879```js
1880let name = new contact.Name();
1881name.familyName = "familyName";
1882name.fullName = "fullName";
1883```
1884
1885
1886## NickName
1887
1888Defines a contact's nickname.
1889
1890**System capability**: SystemCapability.Applications.ContactsData
1891
1892| Name    |   Type  | Readable| Writable| Description          |
1893| -------- | -------- | ---- | ---- | -------------- |
1894| nickName | string   | Yes  | Yes  | Contact nickname.|
1895
1896
1897**Example**
1898
1899  Create contact data in JSON format:
1900
1901```js
1902let nickName = {
1903    nickName: "nickName"
1904};
1905```
1906
1907  Or, create data by configuring a **NickName** object.
1908
1909```js
1910let nickName = new contact.NickName();
1911nickName.nickName = "nickName";
1912```
1913
1914
1915## Note
1916
1917Defines a contact's note.
1918
1919**System capability**: SystemCapability.Applications.ContactsData
1920
1921| Name       |   Type  | Readable| Writable| Description              |
1922| ----------- | -------- | ---- | ---- | ------------------ |
1923| noteContent | string   | Yes  | Yes  | Notes of the contact.|
1924
1925
1926**Example**
1927
1928  Create contact data in JSON format:
1929
1930```js
1931let note = {
1932    noteContent: "noteContent"
1933};
1934```
1935
1936  Or, create data by configuring a **Note** object.
1937
1938```js
1939let note = new contact.Note();
1940note.noteContent = "noteContent";
1941```
1942
1943
1944## Organization
1945
1946Defines a contact's organization.
1947
1948**System capability**: SystemCapability.Applications.ContactsData
1949
1950| Name |   Type  | Readable| Writable| Description      |
1951| ----- | -------- | ---- | ---- | ---------- |
1952| name  | string   | Yes  | Yes  | Organization name.|
1953| title | string   | Yes  | Yes  | Organization title.|
1954
1955
1956**Example**
1957
1958  Create contact data in JSON format:
1959
1960```js
1961let organization = {
1962    name: "name",
1963    title: "title"
1964};
1965```
1966
1967  Or, create data by configuring an **Organization** object.
1968
1969```js
1970let organization = new contact.Organization();
1971organization.name = "name";
1972organization.title = "title";
1973```
1974
1975
1976## PhoneNumber
1977
1978Defines a contact's phone number.
1979
1980**System capability**: SystemCapability.Applications.ContactsData
1981
1982### Constant
1983
1984| Name            | Value  | Description                                            |
1985| ---------------- | ---- | ------------------------------------------------ |
1986| CUSTOM_LABEL     | 0    | Custom phone type.                                |
1987| NUM_HOME         | 1    | Home phone.                                  |
1988| NUM_MOBILE       | 2    | Mobile phone.                                  |
1989| NUM_WORK         | 3    | Work phone.                                  |
1990| NUM_FAX_WORK     | 4    | Work fax.                              |
1991| NUM_FAX_HOME     | 5    | Family fax.                              |
1992| NUM_PAGER        | 6    | Pager.                                |
1993| NUM_OTHER        | 7    | Other phone type.                                  |
1994| NUM_CALLBACK     | 8    | Callback phone.                                  |
1995| NUM_CAR          | 9    | Car phone.                                  |
1996| NUM_COMPANY_MAIN | 10   | Company phone.                                  |
1997| NUM_ISDN         | 11   | Integrated Services Digital Network (ISDN) phone.                |
1998| NUM_MAIN         | 12   | Main phone.                                    |
1999| NUM_OTHER_FAX    | 13   | Other fax phone.                                  |
2000| NUM_RADIO        | 14   | Wireless phone.                                  |
2001| NUM_TELEX        | 15   | Telex phone.                                  |
2002| NUM_TTY_TDD      | 16   | Teletypewriter (TTY) or Test Driven Development (TDD) phone.|
2003| NUM_WORK_MOBILE  | 17   | Work mobile phone.                              |
2004| NUM_WORK_PAGER   | 18   | Work pager.                            |
2005| NUM_ASSISTANT    | 19   | Assistant phone.                                  |
2006| NUM_MMS          | 20   | MMS phone.                                  |
2007| INVALID_LABEL_ID | -1   | Invalid phone type.                                  |
2008
2009
2010### Attributes
2011
2012| Name       |   Type  | Readable| Writable| Description              |
2013| ----------- | -------- | ---- | ---- | ------------------ |
2014| labelName   | string   | Yes  | Yes  | Phone number type.|
2015| phoneNumber | string   | Yes  | Yes  | Phone number.        |
2016| labelId     | number   | Yes  | Yes  | Phone number ID.    |
2017
2018
2019**Example**
2020
2021  Create contact data in JSON format:
2022
2023```js
2024let phoneNumber = {
2025    phoneNumber: "138xxxxxxxx",
2026    labelId: contact.PhoneNumber.NUM_HOME
2027};
2028```
2029
2030  Or, create data by configuring a new **PhoneNumber** object.
2031
2032```js
2033let phoneNumber = new contact.PhoneNumber();
2034phoneNumber.phoneNumber = "138xxxxxxxx";
2035```
2036
2037
2038## Portrait
2039
2040Defines a contact's portrait.
2041
2042**System capability**: SystemCapability.Applications.ContactsData
2043
2044| Name|   Type  | Readable| Writable| Description          |
2045| ---- | -------- | ---- | ---- | -------------- |
2046| uri  | string   | Yes  | Yes  | Contact portrait.|
2047
2048
2049**Example**
2050
2051  Create contact data in JSON format:
2052
2053```js
2054let portrait = {
2055    uri: "uri"
2056};
2057```
2058
2059  Or, create data by configuring a new **Portrait** object.
2060
2061```js
2062let portrait = new contact.Portrait();
2063portrait.uri = "uri";
2064```
2065
2066
2067## PostalAddress
2068
2069Defines a contact's postal address.
2070
2071**System capability**: SystemCapability.Applications.ContactsData
2072
2073### Constant
2074
2075| Name            | Value  | Description                |
2076| ---------------- | ---- | -------------------- |
2077| CUSTOM_LABEL     | 0    | Custom postal address type.|
2078| ADDR_HOME        | 1    | Home address.      |
2079| ADDR_WORK        | 2    | Work address.      |
2080| ADDR_OTHER       | 3    | Other addresses.      |
2081| INVALID_LABEL_ID | -1   | Invalid address type.      |
2082
2083
2084### Attributes
2085
2086| Name         |   Type  | Readable| Writable| Description                      |
2087| ------------- | -------- | ---- | ---- | -------------------------- |
2088| city          | string   | Yes  | Yes  | City where the contact is located.        |
2089| country       | string   | Yes  | Yes  | Country/Region where the contact is located.        |
2090| labelName     | string   | Yes  | Yes  | Postal address type.        |
2091| neighborhood  | string   | Yes  | Yes  | Neighbor of the contact.            |
2092| pobox         | string   | Yes  | Yes  | Email of the contact.            |
2093| postalAddress | string   | Yes  | Yes  | Postal address of the contact.        |
2094| postcode      | string   | Yes  | Yes  | Postal code of the region where the contact is located.|
2095| region        | string   | Yes  | Yes  | Area where the contact is located.        |
2096| street        | string   | Yes  | Yes  | Street where the contact resides.        |
2097| labelId       | number   | Yes  | Yes  | Postal address ID.            |
2098
2099
2100**Example**
2101
2102  Create contact data in JSON format:
2103
2104```js
2105let postalAddress = {
2106    city: "city"
2107};
2108```
2109
2110  Or, create data by configuring a new **PostalAddress** object.
2111
2112```js
2113let postalAddress = new contact.PostalAddress();
2114postalAddress.city = "city";
2115```
2116
2117
2118## Relation
2119
2120Defines a contact's relationship.
2121
2122**System capability**: SystemCapability.Applications.ContactsData
2123
2124### Constant
2125
2126| Name                     | Value  | Description              |
2127| ------------------------- | ---- | ------------------ |
2128| CUSTOM_LABEL              | 0    | Custom relationship.  |
2129| RELATION_ASSISTANT        | 1    | Assistant.    |
2130| RELATION_BROTHER          | 2    | Sibling.    |
2131| RELATION_CHILD            | 3    | Child.    |
2132| RELATION_DOMESTIC_PARTNER | 4    | Domestic partner.|
2133| RELATION_FATHER           | 5    | Father.    |
2134| RELATION_FRIEND           | 6    | Friend.    |
2135| RELATION_MANAGER          | 7    | Manager.  |
2136| RELATION_MOTHER           | 8    | Mother.    |
2137| RELATION_PARENT           | 9    | Parent.    |
2138| RELATION_PARTNER          | 10   | Partner.|
2139| RELATION_REFERRED_BY      | 11   | Referrer.  |
2140| RELATION_RELATIVE         | 12   | Relative.    |
2141| RELATION_SISTER           | 13   | Sister.    |
2142| RELATION_SPOUSE           | 14   | Spouse.    |
2143| INVALID_LABEL_ID          | -1   | Invalid relationship.  |
2144
2145
2146### Attributes
2147
2148| Name        |   Type  | Readable| Writable| Description          |
2149| ------------ | -------- | ---- | ---- | -------------- |
2150| labelName    | string   | Yes  | Yes  | Relationship type.|
2151| relationName | string   | Yes  | Yes  | Relationship name.    |
2152| labelId      | number   | Yes  | Yes  | Relationship ID.    |
2153
2154
2155**Example**
2156
2157  Create contact data in JSON format:
2158
2159```js
2160let relation = {
2161    relationName: "relationName",
2162    labelId: contact.Relation.RELATION_ASSISTANT
2163};
2164```
2165
2166  Or, create data by configuring a new **Relation** object.
2167
2168```js
2169let relation = new contact.Relation();
2170relation.relationName = "relationName";
2171relation.labelId = contact.Relation.RELATION_ASSISTANT;
2172```
2173
2174
2175## SipAddress
2176
2177Defines a contact's SIP address.
2178
2179**System capability**: SystemCapability.Applications.ContactsData
2180
2181### Constant
2182
2183| Name            | Value  | Description                               |
2184| ---------------- | ---- | ----------------------------------- |
2185| CUSTOM_LABEL     | 0    | Custom SIP address.|
2186| SIP_HOME         | 1    | Home SIP address.  |
2187| SIP_WORK         | 2    | Work SIP address.  |
2188| SIP_OTHER        | 3    | Other SIP address.  |
2189| INVALID_LABEL_ID | -1   | Invalid SIP address.  |
2190
2191
2192### Attributes
2193
2194| Name      |   Type  | Readable| Writable| Description                             |
2195| ---------- | -------- | ---- | ---- | --------------------------------- |
2196| labelName  | string   | Yes  | Yes  | SIP address type.|
2197| sipAddress | string   | Yes  | Yes  | SIP address.        |
2198| labelId    | number   | Yes  | Yes  | SIP address ID.    |
2199
2200**Example**
2201
2202  Create contact data in JSON format:
2203
2204```js
2205var sipAddress = {
2206    sipAddress: "sipAddress"
2207};
2208```
2209
2210  Or, create data by configuring a new **SipAddress** object.
2211
2212```js
2213let sipAddress = new contact.SipAddress();
2214sipAddress.sipAddress = "sipAddress";
2215```
2216
2217
2218## Website
2219
2220Defines a contact's website.
2221
2222**System capability**: SystemCapability.Applications.ContactsData
2223
2224| Name   |   Type  | Readable| Writable| Description              |
2225| ------- | -------- | ---- | ---- | ------------------ |
2226| website | string   | Yes  | Yes  | Website of the contact.|
2227
2228
2229**Example**
2230
2231  Create contact data in JSON format:
2232
2233```js
2234let website = {
2235    website: "website"
2236};
2237```
2238
2239  Or, create data by configuring a new **Website** object.
2240
2241```js
2242let website = new contact.Website();
2243website.website = "website";
2244```
2245