未验证 提交 4de3ceda 编写于 作者: 葛亚芳 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-data-preferences.md.

Signed-off-by: N葛亚芳 <geyafang@huawei.com>
上级 d8f0f1a6
...@@ -55,14 +55,14 @@ let preferences = null; ...@@ -55,14 +55,14 @@ let preferences = null;
try { try {
data_preferences.getPreferences(context, 'mystore', function (err, val) { data_preferences.getPreferences(context, 'mystore', function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = val; preferences = val;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -78,14 +78,14 @@ class EntryAbility extends UIAbility { ...@@ -78,14 +78,14 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.getPreferences(this.context, 'mystore', function (err, val) { data_preferences.getPreferences(this.context, 'mystore', function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = val; preferences = val;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -128,10 +128,10 @@ try { ...@@ -128,10 +128,10 @@ try {
preferences = object; preferences = object;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -150,10 +150,10 @@ class EntryAbility extends UIAbility { ...@@ -150,10 +150,10 @@ class EntryAbility extends UIAbility {
preferences = object; preferences = object;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -197,14 +197,14 @@ let preferences = null; ...@@ -197,14 +197,14 @@ let preferences = null;
try { try {
data_preferences.getPreferences(context, { name: 'mystore' }, function (err, val) { data_preferences.getPreferences(context, { name: 'mystore' }, function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = val; preferences = val;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -221,14 +221,14 @@ class EntryAbility extends UIAbility { ...@@ -221,14 +221,14 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, val) { data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = val; preferences = val;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -280,10 +280,10 @@ try { ...@@ -280,10 +280,10 @@ try {
preferences = object; preferences = object;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -302,10 +302,10 @@ class EntryAbility extends UIAbility { ...@@ -302,10 +302,10 @@ class EntryAbility extends UIAbility {
preferences = object; preferences = object;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -350,13 +350,13 @@ let context = featureAbility.getContext(); ...@@ -350,13 +350,13 @@ let context = featureAbility.getContext();
try { try {
data_preferences.deletePreferences(context, 'mystore', function (err) { data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in deleting preferences." ); console.info("Succeeded in deleting preferences." );
}) })
} catch (err) { } catch (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -370,13 +370,13 @@ class EntryAbility extends UIAbility { ...@@ -370,13 +370,13 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.deletePreferences(this.context, 'mystore', function (err) { data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in deleting preferences." ); console.info("Succeeded in deleting preferences." );
}) })
} catch (err) { } catch (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -427,10 +427,10 @@ try { ...@@ -427,10 +427,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in deleting preferences."); console.info("Succeeded in deleting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -446,10 +446,10 @@ class EntryAbility extends UIAbility { ...@@ -446,10 +446,10 @@ class EntryAbility extends UIAbility {
promise.then(() => { promise.then(() => {
console.info("Succeeded in deleting preferences."); console.info("Succeeded in deleting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -495,13 +495,13 @@ let context = featureAbility.getContext(); ...@@ -495,13 +495,13 @@ let context = featureAbility.getContext();
try { try {
data_preferences.deletePreferences(context, { name: 'mystore' }, function (err) { data_preferences.deletePreferences(context, { name: 'mystore' }, function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in deleting preferences." ); console.info("Succeeded in deleting preferences." );
}) })
} catch (err) { } catch (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -515,13 +515,13 @@ class EntryAbility extends UIAbility { ...@@ -515,13 +515,13 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.deletePreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err) { data_preferences.deletePreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in deleting preferences." ); console.info("Succeeded in deleting preferences." );
}) })
} catch (err) { } catch (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -575,10 +575,10 @@ try { ...@@ -575,10 +575,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in deleting preferences."); console.info("Succeeded in deleting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -594,10 +594,10 @@ class EntryAbility extends UIAbility { ...@@ -594,10 +594,10 @@ class EntryAbility extends UIAbility {
promise.then(() => { promise.then(() => {
console.info("Succeeded in deleting preferences."); console.info("Succeeded in deleting preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -635,13 +635,13 @@ let context = featureAbility.getContext(); ...@@ -635,13 +635,13 @@ let context = featureAbility.getContext();
try { try {
data_preferences.removePreferencesFromCache(context, 'mystore', function (err) { data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -655,13 +655,13 @@ class EntryAbility extends UIAbility { ...@@ -655,13 +655,13 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -705,10 +705,10 @@ try { ...@@ -705,10 +705,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -724,10 +724,10 @@ class EntryAbility extends UIAbility { ...@@ -724,10 +724,10 @@ class EntryAbility extends UIAbility {
promise.then(() => { promise.then(() => {
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -763,7 +763,7 @@ let context = featureAbility.getContext(); ...@@ -763,7 +763,7 @@ let context = featureAbility.getContext();
try { try {
data_preferences.removePreferencesFromCacheSync(context, 'mystore'); data_preferences.removePreferencesFromCacheSync(context, 'mystore');
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -777,7 +777,7 @@ class EntryAbility extends UIAbility { ...@@ -777,7 +777,7 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.removePreferencesFromCacheSync(this.context, 'mystore'); data_preferences.removePreferencesFromCacheSync(this.context, 'mystore');
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -823,13 +823,13 @@ let context = featureAbility.getContext(); ...@@ -823,13 +823,13 @@ let context = featureAbility.getContext();
try { try {
data_preferences.removePreferencesFromCache(context, { name: 'mystore' }, function (err) { data_preferences.removePreferencesFromCache(context, { name: 'mystore' }, function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -843,13 +843,13 @@ class EntryAbility extends UIAbility { ...@@ -843,13 +843,13 @@ class EntryAbility extends UIAbility {
try { try {
data_preferences.removePreferencesFromCache(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err) { data_preferences.removePreferencesFromCache(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -902,10 +902,10 @@ try { ...@@ -902,10 +902,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -921,10 +921,10 @@ class EntryAbility extends UIAbility { ...@@ -921,10 +921,10 @@ class EntryAbility extends UIAbility {
promise.then(() => { promise.then(() => {
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
} }
} }
...@@ -970,13 +970,13 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): ...@@ -970,13 +970,13 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;):
try { try {
preferences.get('startup', 'default', function (err, val) { preferences.get('startup', 'default', function (err, val) {
if (err) { if (err) {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in getting value of 'startup'. val: " + val); console.info("Succeeded in getting value of 'startup'. val: " + val);
}) })
} catch (err) { } catch (err) {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1010,10 +1010,10 @@ try { ...@@ -1010,10 +1010,10 @@ try {
promise.then((data) => { promise.then((data) => {
console.info("Succeeded in getting value of 'startup'. Data: " + data); console.info("Succeeded in getting value of 'startup'. Data: " + data);
}).catch((err) => { }).catch((err) => {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1045,7 +1045,7 @@ try { ...@@ -1045,7 +1045,7 @@ try {
let value = preferences.getSync('startup', 'default'); let value = preferences.getSync('startup', 'default');
console.info("Succeeded in getting value of 'startup'. Data: " + value); console.info("Succeeded in getting value of 'startup'. Data: " + value);
} catch(err) { } catch(err) {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1069,7 +1069,7 @@ getAll(callback: AsyncCallback&lt;Object&gt;): void; ...@@ -1069,7 +1069,7 @@ getAll(callback: AsyncCallback&lt;Object&gt;): void;
try { try {
preferences.getAll(function (err, value) { preferences.getAll(function (err, value) {
if (err) { if (err) {
console.info("Failed to get all key-values. code =" + err.code + ", message =" + err.message); console.error("Failed to get all key-values. code =" + err.code + ", message =" + err.message);
return; return;
} }
let allKeys = Object.keys(value); let allKeys = Object.keys(value);
...@@ -1077,7 +1077,7 @@ try { ...@@ -1077,7 +1077,7 @@ try {
console.info("getAll object = " + JSON.stringify(value)); console.info("getAll object = " + JSON.stringify(value));
}) })
} catch (err) { } catch (err) {
console.info("Failed to get all key-values. code =" + err.code + ", message =" + err.message); console.error("Failed to get all key-values. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1106,10 +1106,10 @@ try { ...@@ -1106,10 +1106,10 @@ try {
console.info('getAll keys = ' + allKeys); console.info('getAll keys = ' + allKeys);
console.info("getAll object = " + JSON.stringify(value)); console.info("getAll object = " + JSON.stringify(value));
}).catch((err) => { }).catch((err) => {
console.info("Failed to get all key-values. code =" + err.code + ", message =" + err.message); console.error("Failed to get all key-values. code =" + err.code + ", message =" + err.message);
}) })
} catch (err) { } catch (err) {
console.info("Failed to get all key-values. code =" + err.code + ", message =" + err.message); console.error("Failed to get all key-values. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1136,7 +1136,7 @@ try { ...@@ -1136,7 +1136,7 @@ try {
console.info('getAll keys = ' + allKeys); console.info('getAll keys = ' + allKeys);
console.info("getAll object = " + JSON.stringify(value)); console.info("getAll object = " + JSON.stringify(value));
} catch (err) { } catch (err) {
console.info("Failed to get all key-values. code =" + err.code + ", message =" + err.message); console.error("Failed to get all key-values. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1162,13 +1162,13 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void ...@@ -1162,13 +1162,13 @@ put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
try { try {
preferences.put('startup', 'auto', function (err) { preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in putting value of 'startup'."); console.info("Succeeded in putting value of 'startup'.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1202,10 +1202,10 @@ try { ...@@ -1202,10 +1202,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in putting value of 'startup'."); console.info("Succeeded in putting value of 'startup'.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message);
} }
``` ```
...@@ -1231,7 +1231,7 @@ putSync(key: string, value: ValueType): void ...@@ -1231,7 +1231,7 @@ putSync(key: string, value: ValueType): void
try { try {
preferences.putSync('startup', 'auto'); preferences.putSync('startup', 'auto');
} catch(err) { } catch(err) {
console.info("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to put value of 'startup'. code =" + err.code +", message =" + err.message);
} }
``` ```
...@@ -1257,7 +1257,7 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1257,7 +1257,7 @@ has(key: string, callback: AsyncCallback&lt;boolean&gt;): void
try { try {
preferences.has('startup', function (err, val) { preferences.has('startup', function (err, val) {
if (err) { if (err) {
console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message);
return; return;
} }
if (val) { if (val) {
...@@ -1267,7 +1267,7 @@ try { ...@@ -1267,7 +1267,7 @@ try {
} }
}) })
} catch (err) { } catch (err) {
console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1304,10 +1304,10 @@ try { ...@@ -1304,10 +1304,10 @@ try {
console.info("The key 'startup' dose not contain."); console.info("The key 'startup' dose not contain.");
} }
}).catch((err) => { }).catch((err) => {
console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1343,7 +1343,7 @@ try { ...@@ -1343,7 +1343,7 @@ try {
console.info("The key 'startup' dose not contain."); console.info("The key 'startup' dose not contain.");
} }
} catch(err) { } catch(err) {
console.info("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to check the key 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1369,13 +1369,13 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -1369,13 +1369,13 @@ delete(key: string, callback: AsyncCallback&lt;void&gt;): void
try { try {
preferences.delete('startup', function (err) { preferences.delete('startup', function (err) {
if (err) { if (err) {
console.info("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in deleting the key 'startup'."); console.info("Succeeded in deleting the key 'startup'.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message); console.error("Failed to delete the key 'startup'. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1408,10 +1408,10 @@ try { ...@@ -1408,10 +1408,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in deleting the key 'startup'."); console.info("Succeeded in deleting the key 'startup'.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message);
} }
``` ```
...@@ -1436,7 +1436,7 @@ deleteSync(key: string): void ...@@ -1436,7 +1436,7 @@ deleteSync(key: string): void
try { try {
preferences.deleteSync('startup'); preferences.deleteSync('startup');
} catch(err) { } catch(err) {
console.info("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message); console.error("Failed to delete the key 'startup'. code =" + err.code +", message =" + err.message);
} }
``` ```
...@@ -1461,13 +1461,13 @@ flush(callback: AsyncCallback&lt;void&gt;): void ...@@ -1461,13 +1461,13 @@ flush(callback: AsyncCallback&lt;void&gt;): void
try { try {
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1494,10 +1494,10 @@ try { ...@@ -1494,10 +1494,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1522,13 +1522,13 @@ clear(callback: AsyncCallback&lt;void&gt;): void ...@@ -1522,13 +1522,13 @@ clear(callback: AsyncCallback&lt;void&gt;): void
try { try {
preferences.clear(function (err) { preferences.clear(function (err) {
if (err) { if (err) {
console.info("Failed to clear. code =" + err.code + ", message =" + err.message); console.error("Failed to clear. code =" + err.code + ", message =" + err.message);
return; return;
} }
console.info("Succeeded in clearing."); console.info("Succeeded in clearing.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to clear. code =" + err.code + ", message =" + err.message); console.error("Failed to clear. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1555,10 +1555,10 @@ try { ...@@ -1555,10 +1555,10 @@ try {
promise.then(() => { promise.then(() => {
console.info("Succeeded in clearing."); console.info("Succeeded in clearing.");
}).catch((err) => { }).catch((err) => {
console.info("Failed to clear. code =" + err.code + ", message =" + err.message); console.error("Failed to clear. code =" + err.code + ", message =" + err.message);
}) })
} catch(err) { } catch(err) {
console.info("Failed to clear. code =" + err.code + ", message =" + err.message); console.error("Failed to clear. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1577,7 +1577,7 @@ clearSync(): void ...@@ -1577,7 +1577,7 @@ clearSync(): void
try { try {
preferences.clearSync(); preferences.clearSync();
} catch(err) { } catch(err) {
console.info("Failed to clear. code =" + err.code + ", message =" + err.message); console.error("Failed to clear. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1603,7 +1603,7 @@ on(type: 'change', callback: Callback&lt;{ key : string }&gt;): void ...@@ -1603,7 +1603,7 @@ on(type: 'change', callback: Callback&lt;{ key : string }&gt;): void
try { try {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { if (err) {
console.info("Failed to get preferences."); console.error("Failed to get preferences.");
return; return;
} }
let observer = function (key) { let observer = function (key) {
...@@ -1612,14 +1612,14 @@ try { ...@@ -1612,14 +1612,14 @@ try {
preferences.on('change', observer); preferences.on('change', observer);
preferences.put('startup', 'manual', function (err) { preferences.put('startup', 'manual', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err); console.error("Failed to put the value of 'startup'. Cause: " + err);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. Cause: " + err); console.error("Failed to flush. Cause: " + err);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
...@@ -1627,7 +1627,7 @@ try { ...@@ -1627,7 +1627,7 @@ try {
}) })
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1662,7 +1662,7 @@ on(type: 'multiProcessChange', callback: Callback&lt;{ key : string }&gt;): void ...@@ -1662,7 +1662,7 @@ on(type: 'multiProcessChange', callback: Callback&lt;{ key : string }&gt;): void
try { try {
data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, preferences) { data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, preferences) {
if (err) { if (err) {
console.info("Failed to get preferences."); console.error("Failed to get preferences.");
return; return;
} }
let observer = function (key) { let observer = function (key) {
...@@ -1671,14 +1671,14 @@ try { ...@@ -1671,14 +1671,14 @@ try {
preferences.on('multiProcessChange', observer); preferences.on('multiProcessChange', observer);
preferences.put('startup', 'manual', function (err) { preferences.put('startup', 'manual', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err); console.error("Failed to put the value of 'startup'. Cause: " + err);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. Cause: " + err); console.error("Failed to flush. Cause: " + err);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
...@@ -1686,7 +1686,7 @@ try { ...@@ -1686,7 +1686,7 @@ try {
}) })
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1696,7 +1696,7 @@ try { ...@@ -1696,7 +1696,7 @@ try {
try { try {
data_preferences.getPreferences(this.context, { name: 'mystore' }, function (err, val) { data_preferences.getPreferences(this.context, { name: 'mystore' }, function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences."); console.error("Failed to get preferences.");
return; return;
} }
preferences = val; preferences = val;
...@@ -1705,40 +1705,40 @@ try { ...@@ -1705,40 +1705,40 @@ try {
try { try {
data_preferences.removePreferencesFromCache(this.context, { name: 'mystore' }, function (err) { data_preferences.removePreferencesFromCache(this.context, { name: 'mystore' }, function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = null; preferences = null;
console.info("Succeeded in removing preferences."); console.info("Succeeded in removing preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
} }
try { try {
data_preferences.getPreferences(this.context, { name: 'mystore' }, function (err, val) { data_preferences.getPreferences(this.context, { name: 'mystore' }, function (err, val) {
if (err) { if (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
return; return;
} }
preferences = val; preferences = val;
console.info("Succeeded in getting preferences."); console.info("Succeeded in getting preferences.");
}) })
} catch (err) { } catch (err) {
console.info("Failed to get preferences. code =" + err.code + ", message =" + err.message); console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message);
} }
} }
preferences.on('multiProcessChange', observer); preferences.on('multiProcessChange', observer);
preferences.put('startup', 'manual', function (err) { preferences.put('startup', 'manual', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err); console.error("Failed to put the value of 'startup'. Cause: " + err);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. Cause: " + err); console.error("Failed to flush. Cause: " + err);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
...@@ -1746,7 +1746,7 @@ try { ...@@ -1746,7 +1746,7 @@ try {
}) })
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1771,7 +1771,7 @@ off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void ...@@ -1771,7 +1771,7 @@ off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void
try { try {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) { data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { if (err) {
console.info("Failed to get preferences."); console.error("Failed to get preferences.");
return; return;
} }
let observer = function (key) { let observer = function (key) {
...@@ -1780,14 +1780,14 @@ try { ...@@ -1780,14 +1780,14 @@ try {
preferences.on('change', observer); preferences.on('change', observer);
preferences.put('startup', 'auto', function (err) { preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err); console.error("Failed to put the value of 'startup'. Cause: " + err);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. Cause: " + err); console.error("Failed to flush. Cause: " + err);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
...@@ -1796,7 +1796,7 @@ try { ...@@ -1796,7 +1796,7 @@ try {
}) })
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
...@@ -1821,7 +1821,7 @@ off(type: 'multiProcessChange', callback?: Callback&lt;{ key : string }&gt;): vo ...@@ -1821,7 +1821,7 @@ off(type: 'multiProcessChange', callback?: Callback&lt;{ key : string }&gt;): vo
try { try {
data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, preferences) { data_preferences.getPreferences(this.context, { name: 'mystore', dataGroupId:'myId' }, function (err, preferences) {
if (err) { if (err) {
console.info("Failed to get preferences."); console.error("Failed to get preferences.");
return; return;
} }
let observer = function (key) { let observer = function (key) {
...@@ -1830,14 +1830,14 @@ try { ...@@ -1830,14 +1830,14 @@ try {
preferences.on('multiProcessChange', observer); preferences.on('multiProcessChange', observer);
preferences.put('startup', 'auto', function (err) { preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err); console.error("Failed to put the value of 'startup'. Cause: " + err);
return; return;
} }
console.info("Succeeded in putting the value of 'startup'."); console.info("Succeeded in putting the value of 'startup'.");
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush. Cause: " + err); console.error("Failed to flush. Cause: " + err);
return; return;
} }
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
...@@ -1846,7 +1846,7 @@ try { ...@@ -1846,7 +1846,7 @@ try {
}) })
}) })
} catch (err) { } catch (err) {
console.info("Failed to flush. code =" + err.code + ", message =" + err.message); console.error("Failed to flush. code =" + err.code + ", message =" + err.message);
} }
``` ```
## ValueType ## ValueType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册