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