1e41f4b71Sopenharmony_ci# Update an Asset (C/C++)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Available APIs
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci 
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciYou can use [OH_Asset_Update](../../reference/apis-asset-store-kit/_asset_api.md#oh_asset_update) to update an asset.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciThe following table describes the attributes for updating an asset.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci>**NOTE**
12e41f4b71Sopenharmony_ci>
13e41f4b71Sopenharmony_ci>In the following table, the attributes starting with **ASSET_TAG_DATA_LABEL** are custom asset attributes reserved. These attributes are not encrypted. Therefore, do not put personal data in these attributes.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci- Attributes in **query**:
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci  | Attribute Name (Asset_Tag)           | Attribute Content (Asset_Value)                                      | Mandatory| Description                                            |
18e41f4b71Sopenharmony_ci  | ------------------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------ |
19e41f4b71Sopenharmony_ci  | ASSET_TAG_ALIAS                 | Type: uint8[]<br>Length: 1-256 bytes                              | Yes    | Asset alias, which uniquely identifies an asset.           |
20e41f4b71Sopenharmony_ci  | ASSET_TAG_ACCESSIBILITY         | Type: uint32_t<br>Value range: see [Asset_Accessibility](../../reference/apis-asset-store-kit/_asset_type.md#asset_accessibility)| No    | Access control based on the lock screen status.                                    |
21e41f4b71Sopenharmony_ci  | ASSET_TAG_REQUIRE_PASSWORD_SET  | Type: bool                                                  | No    | Whether the asset is accessible only when a lock screen password is set.    |
22e41f4b71Sopenharmony_ci  | ASSET_TAG_AUTH_TYPE             | Type: uint32_t<br>Value range: see [Asset_AuthType](../../reference/apis-asset-store-kit/_asset_type.md#asset_authtype)| No    | Type of user authentication required for accessing the asset.                  |
23e41f4b71Sopenharmony_ci  | ASSET_TAG_SYNC_TYPE             | Type: uint32_t<br>Value range: see [Asset_SyncType](../../reference/apis-asset-store-kit/_asset_type.md#asset_synctype)| No    | Type of sync supported by the asset.                          |
24e41f4b71Sopenharmony_ci  | ASSET_TAG_IS_PERSISTENT         | Type: bool                                                  | No    | Whether to retain the asset when the application is uninstalled.                |
25e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_CRITICAL_1 | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service with integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
26e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_CRITICAL_2 | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service with integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
27e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_CRITICAL_3 | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service with integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
28e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_CRITICAL_4 | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service with integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
29e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_1   | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
30e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_2   | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
31e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_3   | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
32e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_4   | Type: uint8[]<br>Length: 1-2048 bytes                          | No    | Asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
33e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_1<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the asset. The value is assigned by the service without integrity protection and will not be synced.|
34e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_2<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the asset. The value is assigned by the service without integrity protection and will not be synced.|
35e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_3<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the asset. The value is assigned by the service without integrity protection and will not be synced.|
36e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_4<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the asset. The value is assigned by the service without integrity protection and will not be synced.|
37e41f4b71Sopenharmony_ci  | ASSET_TAG_REQUIRE_ATTR_ENCRYPTED<sup>13+</sup> | Type: bool| No| Whether to update the customized asset attribute information that is encrypted. By default, the unencrypted, customized asset attribute information is updated.|
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci- Attributes in **attributesToUpdate**:
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci  | Attribute Name (Asset_Tag)| Attribute Content (Asset_Value)         | Mandatory| Description                                            |
42e41f4b71Sopenharmony_ci  | ------------------- | ------------------------------- | -------- | ------------------------------------------------ |
43e41f4b71Sopenharmony_ci  | ASSET_TAG_SECRET    | Type: uint8[]<br>Length: 1-1024 bytes| No    | New asset plaintext.                                    |
44e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_1 | Type: uint8[]<br>Length: 1-2048 bytes| No    | New asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
45e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_2 | Type: uint8[]<br>Length: 1-2048 bytes| No    | New asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
46e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_3 | Type: uint8[]<br>Length: 1-2048 bytes| No    | New asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
47e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_4 | Type: uint8[]<br>Length: 1-2048 bytes| No    | New asset attribute information customized by the service without integrity protection.<br>**NOTE**: The data length is 1 to 512 bytes before API version 12.|
48e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_1<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the new asset. The value is assigned by the service without integrity protection and will not be synced.|
49e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_2<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the new asset. The value is assigned by the service without integrity protection and will not be synced.|
50e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_3<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the new asset. The value is assigned by the service without integrity protection and will not be synced.|
51e41f4b71Sopenharmony_ci  | ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_4<sup>12+</sup> | Type: uint8[]<br>Length: 1-2048 bytes| No| Local attribute information about the new asset. The value is assigned by the service without integrity protection and will not be synced.|
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci## Example
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciUpdate asset **demo_alias** as follows: change the asset plaintext to **demo_pwd_new** and additional attribute to **demo_label_new**.
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci1. Add the dynamic library in the CMake script.
58e41f4b71Sopenharmony_ci   ```txt
59e41f4b71Sopenharmony_ci   target_link_libraries(entry PUBLIC libasset_ndk.z.so)
60e41f4b71Sopenharmony_ci   ```
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci2. Add an asset.
63e41f4b71Sopenharmony_ci   ```c
64e41f4b71Sopenharmony_ci   #include <string.h>
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci   #include "asset/asset_api.h"
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci   void UpdateAsset() {
69e41f4b71Sopenharmony_ci      static const char *ALIAS = "demo_alias";
70e41f4b71Sopenharmony_ci      static const char *SECRET = "demo_pwd_new";
71e41f4b71Sopenharmony_ci      static const char *LABEL = "demo_label_new";
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci      Asset_Blob alias = { (uint32_t)(strlen(ALIAS)), (uint8_t *)ALIAS };
74e41f4b71Sopenharmony_ci      Asset_Blob new_secret = { (uint32_t)(strlen(SECRET)), (uint8_t *)SECRET };
75e41f4b71Sopenharmony_ci      Asset_Blob new_label = { (uint32_t)(strlen(LABEL)), (uint8_t *)LABEL };
76e41f4b71Sopenharmony_ci      Asset_Attr query[] = { { .tag = ASSET_TAG_ALIAS, .value.blob = alias } };
77e41f4b71Sopenharmony_ci      Asset_Attr attributesToUpdate[] = {
78e41f4b71Sopenharmony_ci         { .tag = ASSET_TAG_SECRET, .value.blob = new_secret },
79e41f4b71Sopenharmony_ci         { .tag = ASSET_TAG_DATA_LABEL_NORMAL_1, .value.blob = new_label },
80e41f4b71Sopenharmony_ci      };
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci      int32_t ret = OH_Asset_Update(query, sizeof(query) / sizeof(query[0]), attributesToUpdate,
83e41f4b71Sopenharmony_ci                                    sizeof(attributesToUpdate) / sizeof(attributesToUpdate[0]));
84e41f4b71Sopenharmony_ci      if (ret == ASSET_SUCCESS) {
85e41f4b71Sopenharmony_ci         // Asset updated successfully.
86e41f4b71Sopenharmony_ci      } else {
87e41f4b71Sopenharmony_ci         // Failed to update Asset.
88e41f4b71Sopenharmony_ci      }
89e41f4b71Sopenharmony_ci   }
90e41f4b71Sopenharmony_ci   ```
91