提交 d2b7934f 编写于 作者: P PaDoBoo

ohos Handling API interface integrity and consistency

Signed-off-by: NPaDoBoo <xuejianwu@huawei.com>
上级 114289f0
...@@ -79,8 +79,8 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt; ...@@ -79,8 +79,8 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt;
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_Preferences from '@ohos.data.preferences' import data_Preferences from '@ohos.data.preferences'
var path = this.context.getDataBaseDir() var path = this.context.getDataBaseDir()
let promise = data_Preferences.getPreferences(this.context, 'mystore') let promisePre = data_Preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => { promisePre.then((preferences) => {
preferences.putSync('startup', 'auto') preferences.putSync('startup', 'auto')
preferences.flushSync() preferences.flushSync()
}).catch((err) => { }).catch((err) => {
...@@ -141,8 +141,8 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt; ...@@ -141,8 +141,8 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt;
``` ```
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_Preferences from '@ohos.data.preferences' import data_Preferences from '@ohos.data.preferences'
let promise = data_Preferences.deletePreferences(this.context, 'mystore') let promisedelPre = data_Preferences.deletePreferences(this.context, 'mystore')
promise.then(() => { promisedelPre.then(() => {
console.info("Deleted successfully.") console.info("Deleted successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Deleted failed with err: " + err) console.info("Deleted failed with err: " + err)
...@@ -206,8 +206,8 @@ removePreferencesFromCache(context: Context, name: string): Promise&lt;void&gt; ...@@ -206,8 +206,8 @@ removePreferencesFromCache(context: Context, name: string): Promise&lt;void&gt;
``` ```
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_Preferences from '@ohos.data.preferences' import data_Preferences from '@ohos.data.preferences'
let promise = data_Preferences.removePreferencesFromCache(this.context, 'mystore') let promiserevPre = data_Preferences.removePreferencesFromCache(this.context, 'mystore')
promise.then(() => { promiserevPre.then(() => {
console.info("Removed preferences from cache successfully.") console.info("Removed preferences from cache successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Removed preferences from cache failed with err: " + err) console.info("Removed preferences from cache failed with err: " + err)
...@@ -272,8 +272,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; ...@@ -272,8 +272,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
- 示例: - 示例:
``` ```
let promise = preferences.get('startup', 'default') let promiseget = preferences.get('startup', 'default')
promise.then((value) => { promiseget.then((value) => {
console.info("The value of startup is " + value) console.info("The value of startup is " + value)
}).catch((err) => { }).catch((err) => {
console.info("Get the value of startup failed with err: " + err) console.info("Get the value of startup failed with err: " + err)
...@@ -333,8 +333,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt; ...@@ -333,8 +333,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = preferences.put('startup', 'auto') let promiseput = preferences.put('startup', 'auto')
promise.then(() => { promiseput.then(() => {
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Put the value of startup failed with err: " + err) console.info("Put the value of startup failed with err: " + err)
...@@ -399,8 +399,8 @@ has(key: string): Promise&lt;boolean&gt; ...@@ -399,8 +399,8 @@ has(key: string): Promise&lt;boolean&gt;
- 示例: - 示例:
``` ```
let promise = preferences.has('startup') let promisehas = preferences.has('startup')
promise.then((isExist) => { promisehas.then((isExist) => {
if (isExist) { if (isExist) {
console.info("The key of startup is contained.") console.info("The key of startup is contained.")
} }
...@@ -460,8 +460,8 @@ delete(key: string): Promise&lt;void&gt; ...@@ -460,8 +460,8 @@ delete(key: string): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = preferences.delete('startup') let promisedel = preferences.delete('startup')
promise.then(() => { promisedel.then(() => {
console.info("Deleted startup key successfully.") console.info("Deleted startup key successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Delete startup key failed with err: " + err) console.info("Delete startup key failed with err: " + err)
...@@ -513,8 +513,8 @@ flush(): Promise&lt;void&gt; ...@@ -513,8 +513,8 @@ flush(): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = preferences.flush() let promiseflush = preferences.flush()
promise.then(() => { promiseflush.then(() => {
console.info("Flushed to file successfully.") console.info("Flushed to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Flush to file failed with err: " + err) console.info("Flush to file failed with err: " + err)
...@@ -566,8 +566,8 @@ clear(): Promise&lt;void&gt; ...@@ -566,8 +566,8 @@ clear(): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = preferences.clear() let promiseclear = preferences.clear()
promise.then(() => { promiseclear.then(() => {
console.info("Cleared to file successfully.") console.info("Cleared to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Clear to file failed with err: " + err) console.info("Clear to file failed with err: " + err)
......
...@@ -111,8 +111,8 @@ getStorage(path: string): Promise&lt;Storage&gt; ...@@ -111,8 +111,8 @@ getStorage(path: string): Promise&lt;Storage&gt;
var context = featureAbility.getContext() var context = featureAbility.getContext()
var path = await context.getFilesDir() var path = await context.getFilesDir()
let promise = dataStorage.getStorage(path + '/mystore') let promisegetSt = dataStorage.getStorage(path + '/mystore')
promise.then((storage) => { promisegetSt.then((storage) => {
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
storage.flushSync() storage.flushSync()
}).catch((err) => { }).catch((err) => {
...@@ -186,8 +186,8 @@ deleteStorage(path: string): Promise&lt;void&gt; ...@@ -186,8 +186,8 @@ deleteStorage(path: string): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = dataStorage.deleteStorage(path + '/mystore') let promisedelSt = dataStorage.deleteStorage(path + '/mystore')
promise.then(() => { promisedelSt.then(() => {
console.info("Deleted successfully.") console.info("Deleted successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Deleted failed with err: " + err) console.info("Deleted failed with err: " + err)
...@@ -266,8 +266,8 @@ removeStorageFromCache(path: string): Promise&lt;void&gt; ...@@ -266,8 +266,8 @@ removeStorageFromCache(path: string): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = dataStorage.removeStorageFromCache(path + '/mystore') let promiserevSt = dataStorage.removeStorageFromCache(path + '/mystore')
promise.then(() => { promiserevSt.then(() => {
console.info("Removed storage from cache successfully.") console.info("Removed storage from cache successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Removed storage from cache failed with err: " + err) console.info("Removed storage from cache failed with err: " + err)
...@@ -360,8 +360,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; ...@@ -360,8 +360,8 @@ get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
- 示例: - 示例:
``` ```
let promise = storage.get('startup', 'default') let promiseget = storage.get('startup', 'default')
promise.then((value) => { promiseget.then((value) => {
console.info("The value of startup is " + value) console.info("The value of startup is " + value)
}).catch((err) => { }).catch((err) => {
console.info("Get the value of startup failed with err: " + err) console.info("Get the value of startup failed with err: " + err)
...@@ -443,8 +443,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt; ...@@ -443,8 +443,8 @@ put(key: string, value: ValueType): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = storage.put('startup', 'auto') let promiseput = storage.put('startup', 'auto')
promise.then(() => { promiseput.then(() => {
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Put the value of startup failed with err: " + err) console.info("Put the value of startup failed with err: " + err)
...@@ -538,8 +538,8 @@ has(key: string): Promise&lt;boolean&gt; ...@@ -538,8 +538,8 @@ has(key: string): Promise&lt;boolean&gt;
- 示例: - 示例:
``` ```
let promise = storage.has('startup') let promisehas = storage.has('startup')
promise.then((isExist) => { promisehas.then((isExist) => {
if (isExist) { if (isExist) {
console.info("The key of startup is contained.") console.info("The key of startup is contained.")
} }
...@@ -620,8 +620,8 @@ delete(key: string): Promise&lt;void&gt; ...@@ -620,8 +620,8 @@ delete(key: string): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = storage.delete('startup') let promisedel = storage.delete('startup')
promise.then(() => { promisedel.then(() => {
console.info("Deleted startup key successfully.") console.info("Deleted startup key successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Delete startup key failed with err: " + err) console.info("Delete startup key failed with err: " + err)
...@@ -689,8 +689,8 @@ flush(): Promise&lt;void&gt; ...@@ -689,8 +689,8 @@ flush(): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = storage.flush() let promiseflush = storage.flush()
promise.then(() => { promiseflush.then(() => {
console.info("Flushed to file successfully.") console.info("Flushed to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Flush to file failed with err: " + err) console.info("Flush to file failed with err: " + err)
...@@ -758,8 +758,8 @@ clear(): Promise&lt;void&gt; ...@@ -758,8 +758,8 @@ clear(): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
let promise = storage.clear() let promiseclear = storage.clear()
promise.then(() => { promiseclear.then(() => {
console.info("Cleared to file successfully.") console.info("Cleared to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Clear to file failed with err: " + err) console.info("Clear to file failed with err: " + err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册