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