• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.telephony.data (Cellular Data)
2
3The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled.
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## Modules to Import
10
11```js
12import data from '@ohos.telephony.data';
13```
14
15## data.getDefaultCellularDataSlotId
16
17getDefaultCellularDataSlotId(callback: AsyncCallback\<number\>): void
18
19Obtains the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
20
21**System capability**: SystemCapability.Telephony.CellularData
22
23**Parameters**
24
25| Name  | Type                   | Mandatory| Description                                      |
26| -------- | ----------------------- | ---- | ------------------------------------------ |
27| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
28
29**Example**
30
31```js
32data.getDefaultCellularDataSlotId((err, data) => {
33    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
34});
35```
36
37## data.getDefaultCellularDataSlotId
38
39getDefaultCellularDataSlotId(): Promise\<number\>
40
41Obtains the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
42
43**System capability**: SystemCapability.Telephony.CellularData
44
45**Return value**
46
47| Type             | Description                                                        |
48| ----------------- | ------------------------------------------------------------ |
49| Promise\<number\> | Promise used to return the result.<br>**0**: card slot 1<br>**1**: card slot 2|
50
51**Example**
52
53```js
54let promise = data.getDefaultCellularDataSlotId();
55promise.then((data) => {
56    console.log(`getDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`);
57}).catch((err) => {
58    console.error(`getDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
59});
60```
61
62## data.getDefaultCellularDataSlotIdSync<sup>9+</sup>
63
64getDefaultCellularDataSlotIdSync(): number
65
66Obtains the default SIM card used for mobile data synchronously.
67
68**System capability**: SystemCapability.Telephony.CellularData
69
70**Return value**
71
72| Type             | Description                                                        |
73| ------ | -------------------------------------------------- |
74| number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
75
76**Example**
77
78```js
79console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
80```
81
82## data.setDefaultCellularDataSlotId
83
84setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void
85
86Sets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
87
88This is a system API.
89
90**Required permission**: ohos.permission.SET_TELEPHONY_STATE
91
92**System capability**: SystemCapability.Telephony.CellularData
93
94**Parameters**
95
96| Name  | Type                 | Mandatory| Description                                                        |
97| -------- | --------------------- | ---- | ------------------------------------------------------------ |
98| slotId   | number                | Yes  | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
99| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                                  |
100
101**Error codes**
102For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
103
104| ID|                 Error Message                    |
105| -------- | -------------------------------------------- |
106| 201      | Permission denied.                           |
107| 401      | Parameter error.                             |
108| 8300001  | Invalid parameter value.                     |
109| 8300002  | Operation failed. Cannot connect to service. |
110| 8300003  | System internal error.                       |
111| 8300004  | Do not have sim card.                        |
112| 8300999  | Unknown error code.                          |
113| 8301001  | SIM card is not activated.                   |
114
115**Example**
116
117```js
118data.setDefaultCellularDataSlotId(0, (err, data) => {
119    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
120});
121```
122
123## data.setDefaultCellularDataSlotId
124
125setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
126
127Sets the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
128
129This is a system API.
130
131**Required permission**: ohos.permission.SET_TELEPHONY_STATE
132
133**System capability**: SystemCapability.Telephony.CellularData
134
135**Parameters**
136
137| Name| Type  | Mandatory| Description                                                        |
138| ------ | ------ | ---- | ------------------------------------------------------------ |
139| slotId | number | Yes  | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
140
141**Return value**
142
143| Type           | Description                           |
144| --------------- | ------------------------------- |
145| Promise\<void\> | Promise used to return the result.|
146
147**Error codes**
148For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
149
150| ID|                 Error Message                    |
151| -------- | -------------------------------------------- |
152| 201      | Permission denied.                           |
153| 401      | Parameter error.                             |
154| 8300001  | Invalid parameter value.                     |
155| 8300002  | Operation failed. Cannot connect to service. |
156| 8300003  | System internal error.                       |
157| 8300004  | Do not have sim card.                        |
158| 8300999  | Unknown error code.                          |
159| 8301001  | SIM card is not activated.                   |
160
161**Example**
162
163```js
164let promise = data.setDefaultCellularDataSlotId(0);
165promise.then((data) => {
166    console.log(`setDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`);
167}).catch((err) => {
168    console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
169});
170```
171
172## data.getCellularDataFlowType
173
174getCellularDataFlowType(callback: AsyncCallback\<DataFlowType\>): void
175
176Obtains the cellular data flow type, which can be uplink or downlink. This API uses an asynchronous callback to return the result.
177
178**System capability**: SystemCapability.Telephony.CellularData
179
180**Parameters**
181
182| Name  | Type                                          | Mandatory| Description      |
183| -------- | ---------------------------------------------- | ---- | ---------- |
184| callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes  | Callback used to return the result.|
185
186**Example**
187
188```js
189data.getCellularDataFlowType((err, data) => {
190    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
191});
192```
193
194## data.getCellularDataFlowType
195
196getCellularDataFlowType(): Promise\<DataFlowType\>
197
198Obtains the cellular data flow type, which can be uplink or downlink. This API uses a promise to return the result.
199
200**System capability**: SystemCapability.Telephony.CellularData
201
202**Return value**
203
204| Type                                    | Description                                           |
205| ---------------------------------------- | ----------------------------------------------- |
206| Promise\<[DataFlowType](#dataflowtype)\> | Promise used to return the result. |
207
208**Example**
209
210```js
211let promise = data.getCellularDataFlowType();
212promise.then((data) => {
213    console.log(`test success, promise: data->${JSON.stringify(data)}`);
214}).catch((err) => {
215    console.error(`test fail, promise: err->${JSON.stringify(err)}`);
216});
217```
218
219## data.getCellularDataState
220
221getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void
222
223Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result.
224
225**System capability**: SystemCapability.Telephony.CellularData
226
227**Parameters**
228
229| Name  | Type                                                  | Mandatory| Description      |
230| -------- | ------------------------------------------------------ | ---- | ---------- |
231| callback | AsyncCallback\<[DataConnectState](#dataconnectstate)\> | Yes  | Callback used to return the result.|
232
233**Example**
234
235```js
236data.getCellularDataState((err, data) => {
237    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
238});
239```
240
241## data.getCellularDataState
242
243getCellularDataState(): Promise\<DataConnectState\>
244
245Obtains the connection status of the PS domain. This API uses a promise to return the result.
246
247**System capability**: SystemCapability.Telephony.CellularData
248
249**Return value**
250
251| Type                                            | Description                                 |
252| ------------------------------------------------ | ------------------------------------- |
253| Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.|
254
255**Example**
256
257```js
258let promise = data.getCellularDataState();
259promise.then((data) => {
260    console.log(`test success, promise: data->${JSON.stringify(data)}`);
261}).catch((err) => {
262    console.error(`test fail, promise: err->${JSON.stringify(err)}`);
263});
264```
265
266## data.isCellularDataEnabled
267
268isCellularDataEnabled(callback: AsyncCallback\<boolean\>): void
269
270Checks whether the cellular data service is enabled. This API uses an asynchronous callback to return the result.
271
272**Required permission**: ohos.permission.GET_NETWORK_INFO
273
274**System capability**: SystemCapability.Telephony.CellularData
275
276**Parameters**
277
278| Name  | Type                    | Mandatory| Description                                                        |
279| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
280| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
281
282**Error codes**
283For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
284
285| ID|                 Error Message                    |
286| -------- | -------------------------------------------- |
287| 201      | Permission denied.                           |
288| 401      | Parameter error.                             |
289| 8300001  | Invalid parameter value.                     |
290| 8300002  | Operation failed. Cannot connect to service. |
291| 8300003  | System internal error.                       |
292| 8300999  | Unknown error code.                          |
293
294**Example**
295
296```js
297data.isCellularDataEnabled((err, data) => {
298    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
299});
300```
301
302## data.isCellularDataEnabled
303
304isCellularDataEnabled(): Promise\<boolean\>
305
306Checks whether the cellular data service is enabled. This API uses a promise to return the result.
307
308**Required permission**: ohos.permission.GET_NETWORK_INFO
309
310**System capability**: SystemCapability.Telephony.CellularData
311
312**Return value**
313
314| Type              | Description                                                        |
315| ------------------ | ------------------------------------------------------------ |
316| Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
317
318**Error codes**
319For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
320
321| ID|                 Error Message                    |
322| -------- | -------------------------------------------- |
323| 201      | Permission denied.                           |
324| 401      | Parameter error.                             |
325| 8300001  | Invalid parameter value.                     |
326| 8300002  | Operation failed. Cannot connect to service. |
327| 8300003  | System internal error.                       |
328| 8300999  | Unknown error code.                          |
329
330**Example**
331
332```js
333let promise = data.isCellularDataEnabled();
334promise.then((data) => {
335    console.log(`test success, promise: data->${JSON.stringify(data)}`);
336}).catch((err) => {
337    console.error(`test fail, promise: err->${JSON.stringify(err)}`);
338});
339```
340
341## data.isCellularDataRoamingEnabled
342
343isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\<boolean\>): void
344
345Checks whether roaming is enabled for the cellular data service. This API uses an asynchronous callback to return the result.
346
347**Required permission**: ohos.permission.GET_NETWORK_INFO
348
349**System capability**: SystemCapability.Telephony.CellularData
350
351**Parameters**
352
353| Name  | Type                    | Mandatory| Description                                                        |
354| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
355| slotId   | number                   | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2                    |
356| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
357
358**Error codes**
359For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
360
361| ID|                  Error Message                   |
362| -------- | -------------------------------------------- |
363| 201      | Permission denied.                           |
364| 401      | Parameter error.                             |
365| 8300001  | Invalid parameter value.                     |
366| 8300002  | Operation failed. Cannot connect to service. |
367| 8300003  | System internal error.                       |
368| 8300999  | Unknown error code.                          |
369
370**Example**
371
372```js
373data.isCellularDataRoamingEnabled(0, (err, data) => {
374    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
375});
376```
377
378## data.isCellularDataRoamingEnabled
379
380isCellularDataRoamingEnabled(slotId: number): Promise\<boolean\>
381
382Checks whether roaming is enabled for the cellular data service. This API uses a promise to return the result.
383
384**Required permission**: ohos.permission.GET_NETWORK_INFO
385
386**System capability**: SystemCapability.Telephony.CellularData
387
388**Parameters**
389
390| Name| Type  | Mandatory| Description                                    |
391| ------ | ------ | ---- | ---------------------------------------- |
392| slotId | number | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
393
394**Return value**
395
396| Type              | Description                                                        |
397| ------------------ | ------------------------------------------------------------ |
398| Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
399
400**Error codes**
401For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
402
403| ID|                  Error Message                   |
404| -------- | -------------------------------------------- |
405| 201      | Permission denied.                           |
406| 401      | Parameter error.                             |
407| 8300001  | Invalid parameter value.                     |
408| 8300002  | Operation failed. Cannot connect to service. |
409| 8300003  | System internal error.                       |
410| 8300999  | Unknown error code.                          |
411
412**Example**
413
414```js
415let promise = data.isCellularDataRoamingEnabled(0);
416promise.then((data) => {
417    console.log(`test success, promise: data->${JSON.stringify(data)}`);
418}).catch((err) => {
419    console.error(`test fail, promise: err->${JSON.stringify(err)}`);
420});
421```
422
423## data.enableCellularData
424
425enableCellularData(callback: AsyncCallback<void\>): void
426
427Enables the cellular data service. This API uses an asynchronous callback to return the result.
428
429This is a system API.
430
431**Required permission**: ohos.permission.SET_TELEPHONY_STATE
432
433**System capability**: SystemCapability.Telephony.CellularData
434
435**Parameters**
436
437| Name  | Type                 | Mandatory| Description      |
438| -------- | --------------------- | ---- | ---------- |
439| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
440
441**Error codes**
442For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
443
444| ID|                  Error Message                   |
445| -------- | -------------------------------------------- |
446| 201      | Permission denied.                           |
447| 401      | Parameter error.                             |
448| 8300001  | Invalid parameter value.                     |
449| 8300002  | Operation failed. Cannot connect to service. |
450| 8300003  | System internal error.                       |
451| 8300999  | Unknown error code.                          |
452
453**Example**
454
455```js
456data.enableCellularData((err, data) => {
457    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
458});
459```
460
461## data.enableCellularData
462
463enableCellularData(): Promise<void\>
464
465Enables the cellular data service. This API uses a promise to return the result.
466
467This is a system API.
468
469**Required permission**: ohos.permission.SET_TELEPHONY_STATE
470
471**System capability**: SystemCapability.Telephony.CellularData
472
473**Return value**
474
475| Type           | Description                   |
476| --------------- | ----------------------- |
477| Promise\<void\> | Promise used to return the result.|
478
479**Error codes**
480For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
481
482| ID|                  Error Message                   |
483| -------- | -------------------------------------------- |
484| 201      | Permission denied.                           |
485| 401      | Parameter error.                             |
486| 8300001  | Invalid parameter value.                     |
487| 8300002  | Operation failed. Cannot connect to service. |
488| 8300003  | System internal error.                       |
489| 8300999  | Unknown error code.                          |
490
491**Example**
492
493```js
494let promise = data.enableCellularData();
495promise.then((data) => {
496    console.log(`enableCellularData success, promise: data->${JSON.stringify(data)}`);
497}).catch((err) => {
498    console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`);
499});
500```
501
502## data.disableCellularData
503
504disableCellularData(callback: AsyncCallback<void\>): void
505
506Disables the cellular data service. This API uses an asynchronous callback to return the result.
507
508This is a system API.
509
510**Required permission**: ohos.permission.SET_TELEPHONY_STATE
511
512**System capability**: SystemCapability.Telephony.CellularData
513
514**Parameters**
515
516| Name  | Type                 | Mandatory| Description      |
517| -------- | --------------------- | ---- | ---------- |
518| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
519
520**Error codes**
521For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
522
523| ID|                  Error Message                   |
524| -------- | -------------------------------------------- |
525| 201      | Permission denied.                           |
526| 401      | Parameter error.                             |
527| 8300001  | Invalid parameter value.                     |
528| 8300002  | Operation failed. Cannot connect to service. |
529| 8300003  | System internal error.                       |
530| 8300999  | Unknown error code.                          |
531
532**Example**
533
534```js
535data.disableCellularData((err, data) => {
536    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
537});
538```
539
540## data.disableCellularData
541
542disableCellularData(): Promise<void\>
543
544Disables the cellular data service. This API uses a promise to return the result.
545
546This is a system API.
547
548**Required permission**: ohos.permission.SET_TELEPHONY_STATE
549
550**System capability**: SystemCapability.Telephony.CellularData
551
552**Return value**
553
554| Type           | Description                       |
555| --------------- | --------------------------- |
556| Promise\<void\> | Promise used to return the result.|
557
558**Error codes**
559For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
560
561| ID|                  Error Message                   |
562| -------- | -------------------------------------------- |
563| 201      | Permission denied.                           |
564| 401      | Parameter error.                             |
565| 8300001  | Invalid parameter value.                     |
566| 8300002  | Operation failed. Cannot connect to service. |
567| 8300003  | System internal error.                       |
568| 8300999  | Unknown error code.                          |
569
570**Example**
571
572```js
573let promise = data.disableCellularData();
574promise.then((data) => {
575    console.log(`disableCellularData success, promise: data->${JSON.stringify(data)}`);
576}).catch((err) => {
577    console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`);
578});
579```
580
581## data.enableCellularDataRoaming
582
583enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
584
585Enables the cellular data roaming service. This API uses an asynchronous callback to return the result.
586
587This is a system API.
588
589**Required permission**: ohos.permission.SET_TELEPHONY_STATE
590
591**System capability**: SystemCapability.Telephony.CellularData
592
593**Parameters**
594
595| Name  | Type                 | Mandatory| Description                                    |
596| -------- | --------------------- | ---- | ---------------------------------------- |
597| slotId   | number                | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
598| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                              |
599
600**Error codes**
601For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
602
603| ID|                  Error Message                   |
604| -------- | -------------------------------------------- |
605| 201      | Permission denied.                           |
606| 401      | Parameter error.                             |
607| 8300001  | Invalid parameter value.                     |
608| 8300002  | Operation failed. Cannot connect to service. |
609| 8300003  | System internal error.                       |
610| 8300999  | Unknown error code.                          |
611
612**Example**
613
614```js
615data.enableCellularDataRoaming(0, (err, data) => {
616    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
617});
618```
619
620## data.enableCellularDataRoaming
621
622enableCellularDataRoaming(slotId: number): Promise<void\>
623
624Enables the cellular data roaming service. This API uses a promise to return the result.
625
626This is a system API.
627
628**Required permission**: ohos.permission.SET_TELEPHONY_STATE
629
630**System capability**: SystemCapability.Telephony.CellularData
631
632**Parameters**
633
634| Name| Type  | Mandatory| Description                                    |
635| ------ | ------ | ---- | ---------------------------------------- |
636| slotId | number | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
637
638**Return value**
639
640| Type           | Description                     |
641| --------------- | ------------------------- |
642| Promise\<void\> | Promise used to return the result.|
643
644**Error codes**
645For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
646
647| ID|                  Error Message                   |
648| -------- | -------------------------------------------- |
649| 201      | Permission denied.                           |
650| 401      | Parameter error.                             |
651| 8300001  | Invalid parameter value.                     |
652| 8300002  | Operation failed. Cannot connect to service. |
653| 8300003  | System internal error.                       |
654| 8300999  | Unknown error code.                          |
655
656**Example**
657
658```js
659let promise = data.enableCellularDataRoaming(0);
660promise.then((data) => {
661    console.log(`enableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`);
662}).catch((err) => {
663    console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
664});
665```
666
667## data.disableCellularDataRoaming
668
669disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
670
671Disables the cellular data roaming service. This API uses an asynchronous callback to return the result.
672
673This is a system API.
674
675**Required permission**: ohos.permission.SET_TELEPHONY_STATE
676
677**System capability**: SystemCapability.Telephony.CellularData
678
679**Parameters**
680
681| Name  | Type                 | Mandatory| Description                                    |
682| -------- | --------------------- | ---- | ---------------------------------------- |
683| slotId   | number                | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
684| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                              |
685
686**Error codes**
687For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
688
689| ID|                  Error Message                   |
690| -------- | -------------------------------------------- |
691| 201      | Permission denied.                           |
692| 401      | Parameter error.                             |
693| 8300001  | Invalid parameter value.                     |
694| 8300002  | Operation failed. Cannot connect to service. |
695| 8300003  | System internal error.                       |
696| 8300999  | Unknown error code.                          |
697
698**Example**
699
700```js
701data.disableCellularDataRoaming(0, (err, data) => {
702    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
703});
704```
705
706## data.disableCellularDataRoaming
707
708disableCellularDataRoaming(slotId: number): Promise<void\>
709
710Disables the cellular data roaming service. This API uses a promise to return the result.
711
712This is a system API.
713
714**Required permission**: ohos.permission.SET_TELEPHONY_STATE
715
716**System capability**: SystemCapability.Telephony.CellularData
717
718**Parameters**
719
720| Name| Type  | Mandatory| Description                                    |
721| ------ | ------ | ---- | ---------------------------------------- |
722| slotId | number | Yes  | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
723
724**Return value**
725
726| Type           | Description                     |
727| --------------- | ------------------------- |
728| Promise\<void\> | Promise used to return the result.|
729
730**Error codes**
731For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
732
733| ID|                  Error Message                   |
734| -------- | -------------------------------------------- |
735| 201      | Permission denied.                           |
736| 401      | Parameter error.                             |
737| 8300001  | Invalid parameter value.                     |
738| 8300002  | Operation failed. Cannot connect to service. |
739| 8300003  | System internal error.                       |
740| 8300999  | Unknown error code.                          |
741
742**Example**
743
744```js
745let promise = data.disableCellularDataRoaming(0);
746promise.then((data) => {
747    console.log(`disableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`);
748}).catch((err) => {
749    console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
750});
751```
752
753## DataFlowType
754
755Defines the cellular data flow type.
756
757**System capability**: SystemCapability.Telephony.CellularData
758
759| Name                  | Value  | Description                                      |
760| ---------------------- | ---- | ------------------------------------------ |
761| DATA_FLOW_TYPE_NONE    | 0    | No uplink or downlink data is available.                  |
762| DATA_FLOW_TYPE_DOWN    | 1    | Only the downlink data is available.                        |
763| DATA_FLOW_TYPE_UP      | 2    | Only the uplink data is available.                        |
764| DATA_FLOW_TYPE_UP_DOWN | 3    | Both the uplink data and downlink data are available.                        |
765| DATA_FLOW_TYPE_DORMANT | 4    | No uplink or downlink data is available because the lower-layer link is in the dormant state.|
766
767## DataConnectState
768
769Describes the connection status of a cellular data link.
770
771**System capability**: SystemCapability.Telephony.CellularData
772
773| Name                   | Value  | Description                      |
774| ----------------------- | ---- | -------------------------- |
775| DATA_STATE_UNKNOWN      | -1   | The status of the cellular data link is unknown.    |
776| DATA_STATE_DISCONNECTED | 0    | The cellular data link is disconnected.    |
777| DATA_STATE_CONNECTING   | 1    | The cellular data link is being connected.|
778| DATA_STATE_CONNECTED    | 2    | The cellular data link is connected.  |
779| DATA_STATE_SUSPENDED    | 3    | The cellular data link is suspended.  |
780