未验证 提交 3581782a 编写于 作者: O openharmony_ci 提交者: Gitee

!5596 修复storage示例代码错误

Merge pull request !5596 from lijuntao/master
......@@ -48,7 +48,7 @@ getStorageSync(path: string): Storage
```js
import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage'
let path = '/data/storage/el2/database'
let storage = data_storage.getStorageSync(path + '/mystore')
storage.putSync('startup', 'auto')
storage.flushSync()
......@@ -74,7 +74,7 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void
```js
import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage'
let path = '/data/storage/el2/database'
data_storage.getStorage(path + '/mystore', function (err, storage) {
if (err) {
console.info("Get the storage failed, path: " + path + '/mystore')
......@@ -108,7 +108,7 @@ getStorage(path: string): Promise<Storage>
```js
import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage'
let path = '/data/storage/el2/database'
let getPromise = data_storage.getStorage(path + '/mystore')
getPromise.then((storage) => {
......@@ -135,6 +135,7 @@ deleteStorageSync(path: string): void
**示例:**
```js
let path = '/data/storage/el2/database'
data_storage.deleteStorageSync(path + '/mystore')
```
......@@ -155,6 +156,7 @@ deleteStorage(path: string, callback: AsyncCallback<void>): void
**示例:**
```js
let path = '/data/storage/el2/database'
data_storage.deleteStorage(path + '/mystore', function (err) {
if (err) {
console.info("Deleted failed with err: " + err)
......@@ -185,6 +187,7 @@ deleteStorage(path: string): Promise<void>
**示例:**
```js
let path = '/data/storage/el2/database'
let promisedelSt = data_storage.deleteStorage(path + '/mystore')
promisedelSt.then(() => {
console.info("Deleted successfully.")
......@@ -209,6 +212,7 @@ removeStorageFromCacheSync(path: string): void
**示例:**
```js
let path = '/data/storage/el2/database'
data_storage.removeStorageFromCacheSync(path + '/mystore')
```
......@@ -229,6 +233,7 @@ removeStorageFromCache(path: string, callback: AsyncCallback<void>): void
**示例:**
```js
let path = '/data/storage/el2/database'
data_storage.removeStorageFromCache(path + '/mystore', function (err) {
if (err) {
console.info("Removed storage from cache failed with err: " + err)
......@@ -259,6 +264,7 @@ removeStorageFromCache(path: string): Promise<void>
**示例:**
```js
let path = '/data/storage/el2/database'
let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore')
promiserevSt.then(() => {
console.info("Removed storage from cache successfully.")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册