1# System Attribute<a name="EN-US_TOPIC_0000001162414651"></a> 2 3- [Modules to Import](#en-us_topic_0000001094819718_section370mcpsimp) 4- [Required Permissions](#en-us_topic_0000001094819718_section373mcpsimp) 5- [Functions](#en-us_topic_0000001094819718_section1319529172015) 6- [getSync\(key: string, def?: string\)](#en-us_topic_0000001094819718_section3381192816421) 7- [get\(key: string, callback: AsyncCallback<string\>\)](#en-us_topic_0000001094819718_section19655131534912) 8- [get\(key: string, def: string, callback: AsyncCallback<string\>\)](#en-us_topic_0000001094819718_section045334733915) 9- [get\(key: string, def?: string\)](#en-us_topic_0000001094819718_section10288162818402) 10- [setSync\(key: string, value: string\)](#en-us_topic_0000001094819718_section63102185493) 11- [set\(key: string, value: string, callback: AsyncCallback<void\>\)](#en-us_topic_0000001094819718_section18770184911197) 12- [set\(key: string, def?: string\)](#en-us_topic_0000001094819718_section187724496193) 13 14## Modules to Import<a name="en-us_topic_0000001094819718_section370mcpsimp"></a> 15 16``` 17import parameter from '@ohos.systemparameter' 18``` 19 20## Required Permissions<a name="en-us_topic_0000001094819718_section373mcpsimp"></a> 21 22None 23 24## Functions<a name="en-us_topic_0000001094819718_section1319529172015"></a> 25 26## getSync\(key: string, def?: string\)<a name="en-us_topic_0000001094819718_section3381192816421"></a> 27 28Gets the value of the attribute with the specified key. 29 30**Parameters** 31 32<a name="en-us_topic_0000001094819718_table14473145217456"></a> 33<table><thead align="left"><tr id="en-us_topic_0000001094819718_row1052235294518"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p15522195234514"><a name="en-us_topic_0000001094819718_p15522195234514"></a><a name="en-us_topic_0000001094819718_p15522195234514"></a>Name</p> 34</th> 35<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p1852285215454"><a name="en-us_topic_0000001094819718_p1852285215454"></a><a name="en-us_topic_0000001094819718_p1852285215454"></a>Type</p> 36</th> 37<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p125221452154514"><a name="en-us_topic_0000001094819718_p125221452154514"></a><a name="en-us_topic_0000001094819718_p125221452154514"></a>Mandatory</p> 38</th> 39<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p552214521459"><a name="en-us_topic_0000001094819718_p552214521459"></a><a name="en-us_topic_0000001094819718_p552214521459"></a>Description</p> 40</th> 41</tr> 42</thead> 43<tbody><tr id="en-us_topic_0000001094819718_row165221352124511"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p85221523450"><a name="en-us_topic_0000001094819718_p85221523450"></a><a name="en-us_topic_0000001094819718_p85221523450"></a>key</p> 44</td> 45<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1452275204516"><a name="en-us_topic_0000001094819718_p1452275204516"></a><a name="en-us_topic_0000001094819718_p1452275204516"></a>string</p> 46</td> 47<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p1152275224511"><a name="en-us_topic_0000001094819718_p1152275224511"></a><a name="en-us_topic_0000001094819718_p1152275224511"></a>Yes</p> 48</td> 49<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p175228526455"><a name="en-us_topic_0000001094819718_p175228526455"></a><a name="en-us_topic_0000001094819718_p175228526455"></a>Key of the system attribute</p> 50</td> 51</tr> 52<tr id="en-us_topic_0000001094819718_row12676182816132"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p567652819135"><a name="en-us_topic_0000001094819718_p567652819135"></a><a name="en-us_topic_0000001094819718_p567652819135"></a>def</p> 53</td> 54<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p156769289137"><a name="en-us_topic_0000001094819718_p156769289137"></a><a name="en-us_topic_0000001094819718_p156769289137"></a>string</p> 55</td> 56<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p96763289138"><a name="en-us_topic_0000001094819718_p96763289138"></a><a name="en-us_topic_0000001094819718_p96763289138"></a>No</p> 57</td> 58<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p16761628121319"><a name="en-us_topic_0000001094819718_p16761628121319"></a><a name="en-us_topic_0000001094819718_p16761628121319"></a>Default value</p> 59</td> 60</tr> 61</tbody> 62</table> 63 64**Return Values** 65 66<a name="en-us_topic_0000001094819718_table1926815519481"></a> 67<table><thead align="left"><tr id="en-us_topic_0000001094819718_row92682052486"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="en-us_topic_0000001094819718_p326920564820"><a name="en-us_topic_0000001094819718_p326920564820"></a><a name="en-us_topic_0000001094819718_p326920564820"></a>Type</p> 68</th> 69<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="en-us_topic_0000001094819718_p1126911514486"><a name="en-us_topic_0000001094819718_p1126911514486"></a><a name="en-us_topic_0000001094819718_p1126911514486"></a>Description</p> 70</th> 71</tr> 72</thead> 73<tbody><tr id="en-us_topic_0000001094819718_row12269165164818"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="en-us_topic_0000001094819718_p12269145144816"><a name="en-us_topic_0000001094819718_p12269145144816"></a><a name="en-us_topic_0000001094819718_p12269145144816"></a>string</p> 74</td> 75<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="en-us_topic_0000001094819718_p026955154811"><a name="en-us_topic_0000001094819718_p026955154811"></a><a name="en-us_topic_0000001094819718_p026955154811"></a>System attribute value. If the specified key does not exist, the default value is returned. If no default value has been set, an empty string will be returned.</p> 76</td> 77</tr> 78</tbody> 79</table> 80 81**Example** 82 83``` 84try { 85 var info = parameter.getSync("test.parameter.key"); 86 console.log(JSON.stringify(info)); 87}catch(e){ 88 console.log("getSync unexpected error: " + e); 89} 90``` 91 92## get\(key: string, callback: AsyncCallback<string\>\)<a name="en-us_topic_0000001094819718_section19655131534912"></a> 93 94Gets the value of the attribute with the specified key. 95 96**Parameters** 97 98<a name="en-us_topic_0000001094819718_table76561515144911"></a> 99<table><thead align="left"><tr id="en-us_topic_0000001094819718_row165611155491"><th class="cellrowborder" valign="top" width="10.979547900968782%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p146561115114920"><a name="en-us_topic_0000001094819718_p146561115114920"></a><a name="en-us_topic_0000001094819718_p146561115114920"></a>Name</p> 100</th> 101<th class="cellrowborder" valign="top" width="19.806243272335845%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p2656111554911"><a name="en-us_topic_0000001094819718_p2656111554911"></a><a name="en-us_topic_0000001094819718_p2656111554911"></a>Type</p> 102</th> 103<th class="cellrowborder" valign="top" width="5.930130149721108%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p12656121504916"><a name="en-us_topic_0000001094819718_p12656121504916"></a><a name="en-us_topic_0000001094819718_p12656121504916"></a>Mandatory</p> 104</th> 105<th class="cellrowborder" valign="top" width="63.28407867697427%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p14656415104917"><a name="en-us_topic_0000001094819718_p14656415104917"></a><a name="en-us_topic_0000001094819718_p14656415104917"></a>Description</p> 106</th> 107</tr> 108</thead> 109<tbody><tr id="en-us_topic_0000001094819718_row46561715194912"><td class="cellrowborder" valign="top" width="10.979547900968782%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p11656715154910"><a name="en-us_topic_0000001094819718_p11656715154910"></a><a name="en-us_topic_0000001094819718_p11656715154910"></a>key</p> 110</td> 111<td class="cellrowborder" valign="top" width="19.806243272335845%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p66561515204914"><a name="en-us_topic_0000001094819718_p66561515204914"></a><a name="en-us_topic_0000001094819718_p66561515204914"></a>string</p> 112</td> 113<td class="cellrowborder" valign="top" width="5.930130149721108%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p065691514917"><a name="en-us_topic_0000001094819718_p065691514917"></a><a name="en-us_topic_0000001094819718_p065691514917"></a>Yes</p> 114</td> 115<td class="cellrowborder" valign="top" width="63.28407867697427%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p8656111544920"><a name="en-us_topic_0000001094819718_p8656111544920"></a><a name="en-us_topic_0000001094819718_p8656111544920"></a>Key of the system attribute</p> 116</td> 117</tr> 118<tr id="en-us_topic_0000001094819718_row1263818717506"><td class="cellrowborder" valign="top" width="10.979547900968782%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p663817735014"><a name="en-us_topic_0000001094819718_p663817735014"></a><a name="en-us_topic_0000001094819718_p663817735014"></a>callback</p> 119</td> 120<td class="cellrowborder" valign="top" width="19.806243272335845%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p12638872501"><a name="en-us_topic_0000001094819718_p12638872501"></a><a name="en-us_topic_0000001094819718_p12638872501"></a>AsyncCallback<string></p> 121</td> 122<td class="cellrowborder" valign="top" width="5.930130149721108%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p863847125019"><a name="en-us_topic_0000001094819718_p863847125019"></a><a name="en-us_topic_0000001094819718_p863847125019"></a>Yes</p> 123</td> 124<td class="cellrowborder" valign="top" width="63.28407867697427%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p16638207205014"><a name="en-us_topic_0000001094819718_p16638207205014"></a><a name="en-us_topic_0000001094819718_p16638207205014"></a>Callback function</p> 125</td> 126</tr> 127</tbody> 128</table> 129 130**Return Values** 131 132None. 133 134**Example** 135 136``` 137try { 138 parameter.get("test.parameter.key", function (err, data) { 139 if (err == undefined) { 140 console.log("get test.parameter.key value success:" + data) 141 } else { 142 console.log(" get test.parameter.key value err:" + err.code) 143 }}); 144}catch(e){ 145 console.log("get unexpected error: " + e); 146} 147``` 148 149## get\(key: string, def: string, callback: AsyncCallback<string\>\)<a name="en-us_topic_0000001094819718_section045334733915"></a> 150 151Gets the value of the attribute with the specified key. 152 153**Parameters** 154 155<a name="en-us_topic_0000001094819718_table1545354713914"></a> 156<table><thead align="left"><tr id="en-us_topic_0000001094819718_row11453184743918"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p045394710392"><a name="en-us_topic_0000001094819718_p045394710392"></a><a name="en-us_topic_0000001094819718_p045394710392"></a>Name</p> 157</th> 158<th class="cellrowborder" valign="top" width="20.61%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p7453647113916"><a name="en-us_topic_0000001094819718_p7453647113916"></a><a name="en-us_topic_0000001094819718_p7453647113916"></a>Type</p> 159</th> 160<th class="cellrowborder" valign="top" width="6.18%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p745374763917"><a name="en-us_topic_0000001094819718_p745374763917"></a><a name="en-us_topic_0000001094819718_p745374763917"></a>Mandatory</p> 161</th> 162<th class="cellrowborder" valign="top" width="61.99%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p13453847103918"><a name="en-us_topic_0000001094819718_p13453847103918"></a><a name="en-us_topic_0000001094819718_p13453847103918"></a>Description</p> 163</th> 164</tr> 165</thead> 166<tbody><tr id="en-us_topic_0000001094819718_row2453174773917"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p1545413471396"><a name="en-us_topic_0000001094819718_p1545413471396"></a><a name="en-us_topic_0000001094819718_p1545413471396"></a>key</p> 167</td> 168<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p145416477394"><a name="en-us_topic_0000001094819718_p145416477394"></a><a name="en-us_topic_0000001094819718_p145416477394"></a>string</p> 169</td> 170<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p15454124783916"><a name="en-us_topic_0000001094819718_p15454124783916"></a><a name="en-us_topic_0000001094819718_p15454124783916"></a>Yes</p> 171</td> 172<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p645454720398"><a name="en-us_topic_0000001094819718_p645454720398"></a><a name="en-us_topic_0000001094819718_p645454720398"></a>Key of the system attribute</p> 173</td> 174</tr> 175<tr id="en-us_topic_0000001094819718_row1586513411413"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p4866114116410"><a name="en-us_topic_0000001094819718_p4866114116410"></a><a name="en-us_topic_0000001094819718_p4866114116410"></a>def</p> 176</td> 177<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p286618418410"><a name="en-us_topic_0000001094819718_p286618418410"></a><a name="en-us_topic_0000001094819718_p286618418410"></a>string</p> 178</td> 179<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p148664412416"><a name="en-us_topic_0000001094819718_p148664412416"></a><a name="en-us_topic_0000001094819718_p148664412416"></a>Yes</p> 180</td> 181<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p188663413413"><a name="en-us_topic_0000001094819718_p188663413413"></a><a name="en-us_topic_0000001094819718_p188663413413"></a>Default value</p> 182</td> 183</tr> 184<tr id="en-us_topic_0000001094819718_row34546477396"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p1454134712395"><a name="en-us_topic_0000001094819718_p1454134712395"></a><a name="en-us_topic_0000001094819718_p1454134712395"></a>callback</p> 185</td> 186<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p19454047123915"><a name="en-us_topic_0000001094819718_p19454047123915"></a><a name="en-us_topic_0000001094819718_p19454047123915"></a>AsyncCallback<string></p> 187</td> 188<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p445454783919"><a name="en-us_topic_0000001094819718_p445454783919"></a><a name="en-us_topic_0000001094819718_p445454783919"></a>Yes</p> 189</td> 190<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p1454124713391"><a name="en-us_topic_0000001094819718_p1454124713391"></a><a name="en-us_topic_0000001094819718_p1454124713391"></a>Callback function</p> 191</td> 192</tr> 193</tbody> 194</table> 195 196**Return Values** 197 198None. 199 200**Example** 201 202``` 203try { 204 parameter.get("test.parameter.key", "default", function (err, data) { 205 if (err == undefined) { 206 console.log("get test.parameter.key value success:" + data) 207 } else { 208 console.log(" get test.parameter.key value err:" + err.code) 209 } 210 }); 211}catch(e){ 212 console.log("get unexpected error:" + e) 213} 214``` 215 216## get\(key: string, def?: string\)<a name="en-us_topic_0000001094819718_section10288162818402"></a> 217 218Gets the value of the attribute with the specified key. 219 220**Parameters** 221 222<a name="en-us_topic_0000001094819718_table1028882844020"></a> 223<table><thead align="left"><tr id="en-us_topic_0000001094819718_row132880285407"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p1828872816408"><a name="en-us_topic_0000001094819718_p1828872816408"></a><a name="en-us_topic_0000001094819718_p1828872816408"></a>Name</p> 224</th> 225<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p1328810281407"><a name="en-us_topic_0000001094819718_p1328810281407"></a><a name="en-us_topic_0000001094819718_p1328810281407"></a>Type</p> 226</th> 227<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p72881628154019"><a name="en-us_topic_0000001094819718_p72881628154019"></a><a name="en-us_topic_0000001094819718_p72881628154019"></a>Mandatory</p> 228</th> 229<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p16288172814407"><a name="en-us_topic_0000001094819718_p16288172814407"></a><a name="en-us_topic_0000001094819718_p16288172814407"></a>Description</p> 230</th> 231</tr> 232</thead> 233<tbody><tr id="en-us_topic_0000001094819718_row52888288404"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p4288128194010"><a name="en-us_topic_0000001094819718_p4288128194010"></a><a name="en-us_topic_0000001094819718_p4288128194010"></a>key</p> 234</td> 235<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1528817286404"><a name="en-us_topic_0000001094819718_p1528817286404"></a><a name="en-us_topic_0000001094819718_p1528817286404"></a>string</p> 236</td> 237<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p62895286409"><a name="en-us_topic_0000001094819718_p62895286409"></a><a name="en-us_topic_0000001094819718_p62895286409"></a>Yes</p> 238</td> 239<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p4289142812409"><a name="en-us_topic_0000001094819718_p4289142812409"></a><a name="en-us_topic_0000001094819718_p4289142812409"></a>Key of the system attribute</p> 240</td> 241</tr> 242<tr id="en-us_topic_0000001094819718_row828962817403"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p1289152874016"><a name="en-us_topic_0000001094819718_p1289152874016"></a><a name="en-us_topic_0000001094819718_p1289152874016"></a>def</p> 243</td> 244<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p228922815406"><a name="en-us_topic_0000001094819718_p228922815406"></a><a name="en-us_topic_0000001094819718_p228922815406"></a>string</p> 245</td> 246<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p19289428184020"><a name="en-us_topic_0000001094819718_p19289428184020"></a><a name="en-us_topic_0000001094819718_p19289428184020"></a>No</p> 247</td> 248<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p1428942818407"><a name="en-us_topic_0000001094819718_p1428942818407"></a><a name="en-us_topic_0000001094819718_p1428942818407"></a>Default value</p> 249</td> 250</tr> 251</tbody> 252</table> 253 254**Return Values** 255 256<a name="en-us_topic_0000001094819718_table1644156114210"></a> 257<table><thead align="left"><tr id="en-us_topic_0000001094819718_row16441756114213"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="en-us_topic_0000001094819718_p564413569429"><a name="en-us_topic_0000001094819718_p564413569429"></a><a name="en-us_topic_0000001094819718_p564413569429"></a>Type</p> 258</th> 259<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="en-us_topic_0000001094819718_p2644135684219"><a name="en-us_topic_0000001094819718_p2644135684219"></a><a name="en-us_topic_0000001094819718_p2644135684219"></a>Description</p> 260</th> 261</tr> 262</thead> 263<tbody><tr id="en-us_topic_0000001094819718_row126441156204215"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="en-us_topic_0000001094819718_p146441656144211"><a name="en-us_topic_0000001094819718_p146441656144211"></a><a name="en-us_topic_0000001094819718_p146441656144211"></a>Promise<string></p> 264</td> 265<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="en-us_topic_0000001094819718_p2644115664211"><a name="en-us_topic_0000001094819718_p2644115664211"></a><a name="en-us_topic_0000001094819718_p2644115664211"></a>Promise, which is used to obtain the result asynchronously</p> 266</td> 267</tr> 268</tbody> 269</table> 270 271**Example** 272 273``` 274try { 275 var p = parameter.get("test.parameter.key"); 276 p.then(function (value) { 277 console.log("get test.parameter.key success: " + value); 278 }).catch(function (err) { 279 console.log("get test.parameter.key error: " + err.code); 280 }); 281}catch(e){ 282 console.log("get unexpected error: " + e); 283} 284``` 285 286## setSync\(key: string, value: string\)<a name="en-us_topic_0000001094819718_section63102185493"></a> 287 288Sets a value for the attribute with the specified key. 289 290**Parameters** 291 292<a name="en-us_topic_0000001094819718_table15310418174916"></a> 293<table><thead align="left"><tr id="en-us_topic_0000001094819718_row15311121811495"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p19311101814493"><a name="en-us_topic_0000001094819718_p19311101814493"></a><a name="en-us_topic_0000001094819718_p19311101814493"></a>Name</p> 294</th> 295<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p18311118204915"><a name="en-us_topic_0000001094819718_p18311118204915"></a><a name="en-us_topic_0000001094819718_p18311118204915"></a>Type</p> 296</th> 297<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p11311131894919"><a name="en-us_topic_0000001094819718_p11311131894919"></a><a name="en-us_topic_0000001094819718_p11311131894919"></a>Mandatory</p> 298</th> 299<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p1131161804919"><a name="en-us_topic_0000001094819718_p1131161804919"></a><a name="en-us_topic_0000001094819718_p1131161804919"></a>Description</p> 300</th> 301</tr> 302</thead> 303<tbody><tr id="en-us_topic_0000001094819718_row183114182499"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p12311141816498"><a name="en-us_topic_0000001094819718_p12311141816498"></a><a name="en-us_topic_0000001094819718_p12311141816498"></a>key</p> 304</td> 305<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p931121804918"><a name="en-us_topic_0000001094819718_p931121804918"></a><a name="en-us_topic_0000001094819718_p931121804918"></a>string</p> 306</td> 307<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p10311161874910"><a name="en-us_topic_0000001094819718_p10311161874910"></a><a name="en-us_topic_0000001094819718_p10311161874910"></a>Yes</p> 308</td> 309<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p531161819498"><a name="en-us_topic_0000001094819718_p531161819498"></a><a name="en-us_topic_0000001094819718_p531161819498"></a>Key of the system attribute</p> 310</td> 311</tr> 312<tr id="en-us_topic_0000001094819718_row11371940105211"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p713019471526"><a name="en-us_topic_0000001094819718_p713019471526"></a><a name="en-us_topic_0000001094819718_p713019471526"></a>value</p> 313</td> 314<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1213013472526"><a name="en-us_topic_0000001094819718_p1213013472526"></a><a name="en-us_topic_0000001094819718_p1213013472526"></a>string</p> 315</td> 316<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p18130104735216"><a name="en-us_topic_0000001094819718_p18130104735216"></a><a name="en-us_topic_0000001094819718_p18130104735216"></a>Yes</p> 317</td> 318<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p141301747155214"><a name="en-us_topic_0000001094819718_p141301747155214"></a><a name="en-us_topic_0000001094819718_p141301747155214"></a>System attribute value to set</p> 319</td> 320</tr> 321</tbody> 322</table> 323 324**Return Values** 325 326None. 327 328**Example** 329 330``` 331try { 332 parameter.setSync("test.parameter.key", "default"); 333}catch(e){ 334 console.log("set unexpected error: " + e); 335} 336``` 337 338## set\(key: string, value: string, callback: AsyncCallback<void\>\)<a name="en-us_topic_0000001094819718_section18770184911197"></a> 339 340Sets a value for the attribute with the specified key. 341 342**Parameters** 343 344<a name="en-us_topic_0000001094819718_table97701049101914"></a> 345<table><thead align="left"><tr id="en-us_topic_0000001094819718_row977164981919"><th class="cellrowborder" valign="top" width="10.93141075604053%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p57712497198"><a name="en-us_topic_0000001094819718_p57712497198"></a><a name="en-us_topic_0000001094819718_p57712497198"></a>Name</p> 346</th> 347<th class="cellrowborder" valign="top" width="16.630943102104442%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p1077184911195"><a name="en-us_topic_0000001094819718_p1077184911195"></a><a name="en-us_topic_0000001094819718_p1077184911195"></a>Type</p> 348</th> 349<th class="cellrowborder" valign="top" width="6.819953234606392%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p8771184913196"><a name="en-us_topic_0000001094819718_p8771184913196"></a><a name="en-us_topic_0000001094819718_p8771184913196"></a>Mandatory</p> 350</th> 351<th class="cellrowborder" valign="top" width="65.61769290724864%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p1677116491196"><a name="en-us_topic_0000001094819718_p1677116491196"></a><a name="en-us_topic_0000001094819718_p1677116491196"></a>Description</p> 352</th> 353</tr> 354</thead> 355<tbody><tr id="en-us_topic_0000001094819718_row1771194916198"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p127713497196"><a name="en-us_topic_0000001094819718_p127713497196"></a><a name="en-us_topic_0000001094819718_p127713497196"></a>key</p> 356</td> 357<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1777174912196"><a name="en-us_topic_0000001094819718_p1777174912196"></a><a name="en-us_topic_0000001094819718_p1777174912196"></a>string</p> 358</td> 359<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p577164914199"><a name="en-us_topic_0000001094819718_p577164914199"></a><a name="en-us_topic_0000001094819718_p577164914199"></a>Yes</p> 360</td> 361<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p27711349121916"><a name="en-us_topic_0000001094819718_p27711349121916"></a><a name="en-us_topic_0000001094819718_p27711349121916"></a>Key of the system attribute</p> 362</td> 363</tr> 364<tr id="en-us_topic_0000001094819718_row117711549201917"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p87711149111911"><a name="en-us_topic_0000001094819718_p87711149111911"></a><a name="en-us_topic_0000001094819718_p87711149111911"></a>def</p> 365</td> 366<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1977134961915"><a name="en-us_topic_0000001094819718_p1977134961915"></a><a name="en-us_topic_0000001094819718_p1977134961915"></a>string</p> 367</td> 368<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p13771204911918"><a name="en-us_topic_0000001094819718_p13771204911918"></a><a name="en-us_topic_0000001094819718_p13771204911918"></a>Yes</p> 369</td> 370<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p1177117490192"><a name="en-us_topic_0000001094819718_p1177117490192"></a><a name="en-us_topic_0000001094819718_p1177117490192"></a>Default value</p> 371</td> 372</tr> 373<tr id="en-us_topic_0000001094819718_row17771124917194"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p207728494195"><a name="en-us_topic_0000001094819718_p207728494195"></a><a name="en-us_topic_0000001094819718_p207728494195"></a>callback</p> 374</td> 375<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p2077274961913"><a name="en-us_topic_0000001094819718_p2077274961913"></a><a name="en-us_topic_0000001094819718_p2077274961913"></a>AsyncCallback<void></p> 376</td> 377<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p15772184914197"><a name="en-us_topic_0000001094819718_p15772184914197"></a><a name="en-us_topic_0000001094819718_p15772184914197"></a>Yes</p> 378</td> 379<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p1977244913198"><a name="en-us_topic_0000001094819718_p1977244913198"></a><a name="en-us_topic_0000001094819718_p1977244913198"></a>Callback function.</p> 380</td> 381</tr> 382</tbody> 383</table> 384 385**Return Values** 386 387None. 388 389**Example** 390 391``` 392try { 393 parameter.set("test.parameter.key", "testValue", function (err, data) { 394 if (err == undefined) { 395 console.log("set test.parameter.key value success :" + data) 396 } else { 397 console.log("set test.parameter.key value err:" + err.code) 398 }}); 399}catch(e){ 400 console.log("set unexpected error: " + e); 401} 402``` 403 404## set\(key: string, def?: string\)<a name="en-us_topic_0000001094819718_section187724496193"></a> 405 406Sets a value for the attribute with the specified key. 407 408**Parameters** 409 410<a name="en-us_topic_0000001094819718_table17724498192"></a> 411<table><thead align="left"><tr id="en-us_topic_0000001094819718_row277217498197"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="en-us_topic_0000001094819718_p57724491193"><a name="en-us_topic_0000001094819718_p57724491193"></a><a name="en-us_topic_0000001094819718_p57724491193"></a>Name</p> 412</th> 413<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="en-us_topic_0000001094819718_p6772134931918"><a name="en-us_topic_0000001094819718_p6772134931918"></a><a name="en-us_topic_0000001094819718_p6772134931918"></a>Type</p> 414</th> 415<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="en-us_topic_0000001094819718_p577210499193"><a name="en-us_topic_0000001094819718_p577210499193"></a><a name="en-us_topic_0000001094819718_p577210499193"></a>Mandatory</p> 416</th> 417<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="en-us_topic_0000001094819718_p11773124941911"><a name="en-us_topic_0000001094819718_p11773124941911"></a><a name="en-us_topic_0000001094819718_p11773124941911"></a>Description</p> 418</th> 419</tr> 420</thead> 421<tbody><tr id="en-us_topic_0000001094819718_row677384921911"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p677317495199"><a name="en-us_topic_0000001094819718_p677317495199"></a><a name="en-us_topic_0000001094819718_p677317495199"></a>key</p> 422</td> 423<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p177731049131913"><a name="en-us_topic_0000001094819718_p177731049131913"></a><a name="en-us_topic_0000001094819718_p177731049131913"></a>string</p> 424</td> 425<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p777324918197"><a name="en-us_topic_0000001094819718_p777324918197"></a><a name="en-us_topic_0000001094819718_p777324918197"></a>Yes</p> 426</td> 427<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p13773849191918"><a name="en-us_topic_0000001094819718_p13773849191918"></a><a name="en-us_topic_0000001094819718_p13773849191918"></a>Key of the system attribute</p> 428</td> 429</tr> 430<tr id="en-us_topic_0000001094819718_row13773114921911"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="en-us_topic_0000001094819718_p1777374951915"><a name="en-us_topic_0000001094819718_p1777374951915"></a><a name="en-us_topic_0000001094819718_p1777374951915"></a>def</p> 431</td> 432<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="en-us_topic_0000001094819718_p1877394921916"><a name="en-us_topic_0000001094819718_p1877394921916"></a><a name="en-us_topic_0000001094819718_p1877394921916"></a>string</p> 433</td> 434<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="en-us_topic_0000001094819718_p1177314917194"><a name="en-us_topic_0000001094819718_p1177314917194"></a><a name="en-us_topic_0000001094819718_p1177314917194"></a>No</p> 435</td> 436<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="en-us_topic_0000001094819718_p7773204917199"><a name="en-us_topic_0000001094819718_p7773204917199"></a><a name="en-us_topic_0000001094819718_p7773204917199"></a>Default value</p> 437</td> 438</tr> 439</tbody> 440</table> 441 442**Return Values** 443 444<a name="en-us_topic_0000001094819718_table14773154913191"></a> 445<table><thead align="left"><tr id="en-us_topic_0000001094819718_row877314991912"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="en-us_topic_0000001094819718_p1077313493199"><a name="en-us_topic_0000001094819718_p1077313493199"></a><a name="en-us_topic_0000001094819718_p1077313493199"></a>Type</p> 446</th> 447<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="en-us_topic_0000001094819718_p1677411498195"><a name="en-us_topic_0000001094819718_p1677411498195"></a><a name="en-us_topic_0000001094819718_p1677411498195"></a>Description</p> 448</th> 449</tr> 450</thead> 451<tbody><tr id="en-us_topic_0000001094819718_row1977413496194"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="en-us_topic_0000001094819718_p67742498197"><a name="en-us_topic_0000001094819718_p67742498197"></a><a name="en-us_topic_0000001094819718_p67742498197"></a>Promise<string></p> 452</td> 453<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="en-us_topic_0000001094819718_p4774164916199"><a name="en-us_topic_0000001094819718_p4774164916199"></a><a name="en-us_topic_0000001094819718_p4774164916199"></a>Promise, which is used to obtain the result asynchronously</p> 454</td> 455</tr> 456</tbody> 457</table> 458 459**Example** 460 461``` 462try { 463 var p = para.set("test.parameter.key", "testValue"); 464 p.then(function (value) { 465 console.log("set test.parameter.key success: " + value); 466 }).catch(function (err) { 467 console.log(" set test.parameter.key error: " + err.code); 468 }); 469}catch(e){ 470 console.log("set unexpected error: " + e); 471} 472``` 473 474