1e41f4b71Sopenharmony_ci# @ohos.telephony.data (Cellular Data) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **data** module provides basic mobile data management functions. With the APIs provided by this module, you can set the default slot of the SIM card used for cellular data services and enable or disable cellular data services and data roaming. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci>**NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci>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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci>This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.telephony.data (Cellular Data)](js-apis-telephony-data.md). 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Modules to Import 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci```ts 15e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 16e41f4b71Sopenharmony_ci``` 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## data.setDefaultCellularDataSlotId 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_cisetDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciSets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System API**: This is a system API. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Parameters** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 34e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ------------------------------------------------------------ | 35e41f4b71Sopenharmony_ci| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1.<br>- **1**: card slot 2.| 36e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci**Error codes** 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci| ID| Error Message | 43e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 44e41f4b71Sopenharmony_ci| 201 | Permission denied. | 45e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 46e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 47e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 48e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 49e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 50e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 51e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 52e41f4b71Sopenharmony_ci| 8301001 | SIM card is not activated. | 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**Example** 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci```ts 57e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 58e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_cidata.setDefaultCellularDataSlotId(0, (err: BusinessError) => { 61e41f4b71Sopenharmony_ci if(err){ 62e41f4b71Sopenharmony_ci console.error(`setDefaultCellularDataSlotId fail,callback: err->${JSON.stringify(err)}.`); 63e41f4b71Sopenharmony_ci }else{ 64e41f4b71Sopenharmony_ci console.log(`setDefaultCellularDataSlotId success`); 65e41f4b71Sopenharmony_ci } 66e41f4b71Sopenharmony_ci}); 67e41f4b71Sopenharmony_ci``` 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci## data.setDefaultCellularDataSlotId 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_cisetDefaultCellularDataSlotId(slotId: number): Promise\<void\> 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ciSets the default slot of the SIM card used for mobile data. This API uses a promise to return the result. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci**System API**: This is a system API. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Parameters** 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 84e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ | 85e41f4b71Sopenharmony_ci| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1.<br>- **1**: card slot 2.| 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci**Return value** 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci| Type | Description | 90e41f4b71Sopenharmony_ci| --------------- | ------------------------------- | 91e41f4b71Sopenharmony_ci| Promise\<void\> | Promise used to return the result.| 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**Error codes** 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci| ID| Error Message | 98e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 99e41f4b71Sopenharmony_ci| 201 | Permission denied. | 100e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 101e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 102e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 103e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 104e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 105e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 106e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 107e41f4b71Sopenharmony_ci| 8301001 | SIM card is not activated. | 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci**Example** 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci```ts 112e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 113e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_cidata.setDefaultCellularDataSlotId(0).then(() => { 116e41f4b71Sopenharmony_ci console.log(`setDefaultCellularDataSlotId success.`); 117e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 118e41f4b71Sopenharmony_ci console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`); 119e41f4b71Sopenharmony_ci}); 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci## data.enableCellularData 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_cienableCellularData(callback: AsyncCallback\<void\>): void 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ciEnables the cellular data service. This API uses an asynchronous callback to return the result. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci**System API**: This is a system API. 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci**Parameters** 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 138e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------- | 139e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Error codes** 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci| ID| Error Message | 146e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 147e41f4b71Sopenharmony_ci| 201 | Permission denied. | 148e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 149e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 150e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 151e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 152e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 153e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci**Example** 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci```ts 158e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 159e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_cidata.enableCellularData((err: BusinessError) => { 162e41f4b71Sopenharmony_ci if(err){ 163e41f4b71Sopenharmony_ci console.error(`enableCellularData fail,callback: callback: err->${JSON.stringify(err)}`); 164e41f4b71Sopenharmony_ci }else{ 165e41f4b71Sopenharmony_ci console.log(`enableCellularData success`); 166e41f4b71Sopenharmony_ci } 167e41f4b71Sopenharmony_ci}); 168e41f4b71Sopenharmony_ci``` 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci## data.enableCellularData 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_cienableCellularData(): Promise\<void\> 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ciEnables the cellular data service. This API uses a promise to return the result. 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**System API**: This is a system API. 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci**Return value** 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci| Type | Description | 185e41f4b71Sopenharmony_ci| --------------- | ----------------------- | 186e41f4b71Sopenharmony_ci| Promise\<void\> | Promise used to return the result.| 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci**Error codes** 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci| ID| Error Message | 193e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 194e41f4b71Sopenharmony_ci| 201 | Permission denied. | 195e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 196e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 197e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 198e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci**Example** 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci```ts 203e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 204e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_cidata.enableCellularData().then(() => { 207e41f4b71Sopenharmony_ci console.log(`enableCellularData success.`); 208e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 209e41f4b71Sopenharmony_ci console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`); 210e41f4b71Sopenharmony_ci}); 211e41f4b71Sopenharmony_ci``` 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci## data.disableCellularData 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_cidisableCellularData(callback: AsyncCallback\<void\>): void 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ciDisables the cellular data service. This API uses an asynchronous callback to return the result. 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci**System API**: This is a system API. 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**Parameters** 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 228e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------- | 229e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci**Error codes** 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci| ID| Error Message | 236e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 237e41f4b71Sopenharmony_ci| 201 | Permission denied. | 238e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 239e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 240e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 241e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 242e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 243e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci**Example** 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_ci```ts 248e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 249e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_cidata.disableCellularData((err: BusinessError) => { 252e41f4b71Sopenharmony_ci if(err){ 253e41f4b71Sopenharmony_ci console.error(`disableCellularData fail,callback: callback: err->${JSON.stringify(err)}`); 254e41f4b71Sopenharmony_ci }else{ 255e41f4b71Sopenharmony_ci console.log(`disableCellularData success`); 256e41f4b71Sopenharmony_ci } 257e41f4b71Sopenharmony_ci}); 258e41f4b71Sopenharmony_ci``` 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci## data.disableCellularData 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_cidisableCellularData(): Promise\<void\> 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ciDisables the cellular data service. This API uses a promise to return the result. 265e41f4b71Sopenharmony_ci 266e41f4b71Sopenharmony_ci**System API**: This is a system API. 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 269e41f4b71Sopenharmony_ci 270e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 271e41f4b71Sopenharmony_ci 272e41f4b71Sopenharmony_ci**Return value** 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci| Type | Description | 275e41f4b71Sopenharmony_ci| --------------- | --------------------------- | 276e41f4b71Sopenharmony_ci| Promise\<void\> | Promise used to return the result.| 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ci**Error codes** 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci| ID| Error Message | 283e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 284e41f4b71Sopenharmony_ci| 201 | Permission denied. | 285e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 286e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 287e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 288e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci**Example** 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci```ts 293e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 294e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_cidata.disableCellularData().then(() => { 297e41f4b71Sopenharmony_ci console.log(`disableCellularData success.`); 298e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 299e41f4b71Sopenharmony_ci console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`); 300e41f4b71Sopenharmony_ci}); 301e41f4b71Sopenharmony_ci``` 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci## data.enableCellularDataRoaming 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_cienableCellularDataRoaming(slotId: number, callback: AsyncCallback\<void\>): void 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ciEnables the cellular data roaming service. This API uses an asynchronous callback to return the result. 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci**System API**: This is a system API. 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ci**Parameters** 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 318e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------------------------- | 319e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.| 320e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci**Error codes** 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci| ID| Error Message | 327e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 328e41f4b71Sopenharmony_ci| 201 | Permission denied. | 329e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 330e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 331e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 332e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 333e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 334e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci**Example** 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ci```ts 339e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 340e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_cidata.enableCellularDataRoaming(0, (err: BusinessError) => { 343e41f4b71Sopenharmony_ci if(err){ 344e41f4b71Sopenharmony_ci console.error(`enableCellularDataRoaming fail,callback: err->${JSON.stringify(err)}`); 345e41f4b71Sopenharmony_ci }else{ 346e41f4b71Sopenharmony_ci console.log(`enableCellularDataRoaming success`); 347e41f4b71Sopenharmony_ci } 348e41f4b71Sopenharmony_ci}); 349e41f4b71Sopenharmony_ci``` 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci## data.enableCellularDataRoaming 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_cienableCellularDataRoaming(slotId: number): Promise\<void\> 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ciEnables the cellular data roaming service. This API uses a promise to return the result. 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci**System API**: This is a system API. 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 360e41f4b71Sopenharmony_ci 361e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci**Parameters** 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 366e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- | 367e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.| 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci**Return value** 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci| Type | Description | 372e41f4b71Sopenharmony_ci| --------------- | ------------------------- | 373e41f4b71Sopenharmony_ci| Promise\<void\> | Promise used to return the result.| 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ci**Error codes** 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 378e41f4b71Sopenharmony_ci 379e41f4b71Sopenharmony_ci| ID| Error Message | 380e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 381e41f4b71Sopenharmony_ci| 201 | Permission denied. | 382e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 383e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 384e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 385e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 386e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 387e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci**Example** 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci```ts 392e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 393e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 394e41f4b71Sopenharmony_ci 395e41f4b71Sopenharmony_cidata.enableCellularDataRoaming(0).then(() => { 396e41f4b71Sopenharmony_ci console.log(`enableCellularDataRoaming success.`); 397e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 398e41f4b71Sopenharmony_ci console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); 399e41f4b71Sopenharmony_ci}); 400e41f4b71Sopenharmony_ci``` 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci## data.disableCellularDataRoaming 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_cidisableCellularDataRoaming(slotId: number, callback: AsyncCallback\<void\>): void 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ciDisables the cellular data roaming service. This API uses an asynchronous callback to return the result. 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**System API**: This is a system API. 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci**Parameters** 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 417e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------------------------- | 418e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.| 419e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ci**Error codes** 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci| ID| Error Message | 426e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 427e41f4b71Sopenharmony_ci| 201 | Permission denied. | 428e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 429e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 430e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 431e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 432e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 433e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci**Example** 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci```ts 438e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 439e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_cidata.disableCellularDataRoaming(0, (err: BusinessError) => { 442e41f4b71Sopenharmony_ci if(err){ 443e41f4b71Sopenharmony_ci console.error(`disableCellularDataRoaming fail,callback: err->${JSON.stringify(err)}`); 444e41f4b71Sopenharmony_ci }else{ 445e41f4b71Sopenharmony_ci console.log(`disableCellularDataRoaming success`); 446e41f4b71Sopenharmony_ci } 447e41f4b71Sopenharmony_ci}); 448e41f4b71Sopenharmony_ci``` 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci## data.disableCellularDataRoaming 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_cidisableCellularDataRoaming(slotId: number): Promise\<void\> 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ciDisables the cellular data roaming service. This API uses a promise to return the result. 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci**System API**: This is a system API. 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_TELEPHONY_STATE 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CellularData 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci**Parameters** 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 465e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- | 466e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1.<br>**1**: card slot 2.| 467e41f4b71Sopenharmony_ci 468e41f4b71Sopenharmony_ci**Return value** 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_ci| Type | Description | 471e41f4b71Sopenharmony_ci| --------------- | ------------------------- | 472e41f4b71Sopenharmony_ci| Promise\<void\> | Promise used to return the result.| 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci**Error codes** 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci| ID| Error Message | 479e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 480e41f4b71Sopenharmony_ci| 201 | Permission denied. | 481e41f4b71Sopenharmony_ci| 202 | Non-system applications use system APIs. | 482e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 483e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 484e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 485e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 486e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 487e41f4b71Sopenharmony_ci 488e41f4b71Sopenharmony_ci**Example** 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci```ts 491e41f4b71Sopenharmony_ciimport { data } from '@kit.TelephonyKit'; 492e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_cidata.disableCellularDataRoaming(0).then(() => { 495e41f4b71Sopenharmony_ci console.log(`disableCellularDataRoaming success.`); 496e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 497e41f4b71Sopenharmony_ci console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); 498e41f4b71Sopenharmony_ci}); 499e41f4b71Sopenharmony_ci``` 500