未验证 提交 2433310d 编写于 作者: O openharmony_ci 提交者: Gitee

!11914 [翻译完成】#I5ZV59

Merge pull request !11914 from Annie_wang/PR11268
......@@ -22,10 +22,10 @@ import data_storage from '@ohos.data.storage';
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Type | Readable | Writable | Description |
| ---------------- | ------ | -------- | -------- | ----------------------------------------------------------- |
| MAX_KEY_LENGTH | string | Yes | No | Maximum length of a key. It must be less than 80 bytes. |
| MAX_VALUE_LENGTH | string | Yes | No | Maximum length of a value. It must be less than 8192 bytes. |
| Name | Type| Readable| Writable| Description |
| ---------------- | -------- | ---- | ---- | ------------------------------------- |
| MAX_KEY_LENGTH | number | Yes | No | Maximum length of a key. It must be less than 80 bytes. |
| MAX_VALUE_LENGTH | number | Yes | No | Maximum length of a value. It must be less than 8192 bytes.|
## data_storage.getStorageSync
......@@ -53,8 +53,8 @@ Reads the specified file and loads its data to the **Storage** instance for data
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -86,8 +86,8 @@ Reads the specified file and loads its data to the **Storage** instance for data
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -129,8 +129,8 @@ Reads the specified file and loads its data to the **Storage** instance for data
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -165,8 +165,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -195,8 +195,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -237,8 +237,8 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -271,8 +271,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -302,8 +302,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -344,8 +344,8 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
```js
import featureAbility from '@ohos.ability.featureAbility';
var path;
var context = featureAbility.getContext();
let path;
let context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromise====================>");
......@@ -864,15 +864,15 @@ Subscribes to data changes. The **StorageObserver** needs to be implemented. Whe
**Parameters**
| Name | Type | Description |
| -------- | --------------------------------------------------- | ---------------------------------------- |
| type | string | Event type. The value **change** indicates data change events.|
| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ------ |---------------------------------------- |
| type | string |Yes| Event type. The value **change** indicates data change events.|
| callback | Callback<[StorageObserver](#storageobserver)> | Yes|Callback used to return data changes. |
**Example**
```js
var observer = function (key) {
let observer = function (key) {
console.info("The key of " + key + " changed.");
}
storage.on('change', observer);
......@@ -891,15 +891,15 @@ Unsubscribes from data changes.
**Parameters**
| Name | Type | Description |
| -------- | --------------------------------------------------- | ---------------------------------------- |
| type | string | Event type. The value **change** indicates data change events.|
| callback | Callback<[StorageObserver](#storageobserver)> | Callback used to return data changes. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ------ |---------------------------------------- |
| type | string |Yes| Event type. The value **change** indicates data change events.|
| callback | Callback<[StorageObserver](#storageobserver)> | Yes|Callback used to return data changes. |
**Example**
```js
var observer = function (key) {
let observer = function (key) {
console.info("The key of " + key + " changed.");
}
storage.off('change', observer);
......
# RDB Error Codes
## 14800010 Invalid RDB Name
**Error Message**
Invalid database name.
**Description**
The RDB store name is invalid.
**Possible Causes**
The RDB store name is empty or exceeds 1024 bytes.
**Solution**
Check that the RDB store name is not empty and does not exceed 1024 bytes.
## 14800011 Database File Corrupted
**Error Message**
Database corrupted.
**Description**
The RDB store is corrupted when an API for adding, deleting, querying, or synchronizing data is invoked.
**Possible Causes**
The RDB store file has been corrupted.
**Solution**
1. Restore the RDB store using the backup file.
2. If no RDB backup file is available, delete the RDB store and create it again.
## 14800012 Empty Result Set or Invalid Position
**Error Message**
The result set is empty or the specified location is invalid.
**Description**
The result set is empty or the specified location is invalid.
**Possible Causes**
The result set is empty, or the specified row number in the result set is out of range [0, m - 1]. **m** is **resultsetV9.rowCount**.
**Solution**
Check whether the result set is empty or whether the specified row number is out of range.
## 14800013 Null Column Value or Column Data Type Incompatible With the API Called
**Error Message**
The column value is null or the column type is incompatible.
**Description**
The column value is null, or the column data type is incompatible with the API called.
**Possible Causes**
1. The result set is empty.
2. The current row number in the result set is out of range [0, m - 1]. **m** is **resultsetV9.rowCount**.
3. The column number is out of the range [0, n - 1]. **n** is **resultsetV9.columnCount**.
4. The API called does not support the type of the column data.
**Solution**
1. Check whether the result set is empty.
2. Check whether the row number and column number of the result set are out of range.
3. Check whether the column data type is supported.
# Preferences Error Codes
## 15500010 Failed to Delete Preferences
**Error Message**
Failed to delete preferences.
**Description**
Failed to delete the preference.
**Possible Causes**
The possible causes are as follows:
1. The file name is incorrect.
2. The file path is incorrect.
**Solution**
1. Check that the file name is correct.
2. Check that the file path is correct.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册