@@ -625,7 +625,7 @@ Subscribes to the wallpaper color change event.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'colorChange'** indicates subscribing to the wallpaper color change event.|
| callback | function | Yes| Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolordeprecated).<br>- wallpaperType<br> Wallpaper type.|
| callback | function | Yes| Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br>- **colors**: main color information of the wallpaper. For details, see [RgbaColor](#rgbacolordeprecated).<br>- **wallpaperType**: wallpaper type. |
**Example**
...
...
@@ -657,7 +657,7 @@ Unsubscribes from the wallpaper color change event.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value **'colorChange'** indicates unsubscribing from the wallpaper color change event.|
| callback | function | No| Callback for the wallpaper color change event. If this parameter is not set, this API unsubscribes from all callbacks corresponding to **type**.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolordeprecated).<br>- wallpaperType<br> Wallpaper type.|
| callback | function | No| Callback used for unsubscription. If this parameter is not set, this API unsubscribes from all callbacks of the specified event type.<br>- **colors**: main color information of the wallpaper. For details, see [RgbaColor](#rgbacolordeprecated).<br>- **wallpaperType**: wallpaper type. |
# State Management with Application-level Variables
The state management module provides APIs for data storage, persistent data management, **Ability** data storage, and environment status required by applications.
> **NOTE**
The state management module provides data storage, persistent data management, UIAbility data storage, and environment state required by applications.
>**NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The meanings of T and S in this topic are as follows:
| Type | Description |
| ---- | -------------------------------------- |
| T | Class, number, boolean, string, and arras of these types.|
| S | number, boolean, string. |
## AppStorage
### Link
Link(propName: string): any
For details about how to use AppStorage on the UI, see [AppStorage: Application-wide UI State Storage](../../quick-start/arkts-appstorage.md).
Establishes two-way data binding with the given attribute (specified by **propName**) in AppStorage. If the given attribute exists in AppStorage, the two-way bound data of the attribute in AppStorage is returned.
Any update of the data is synchronized back to AppStorage, which then synchronizes the update to all data and custom components bound to the attribute.
If the given attribute does not exist in AppStorage, **undefined** is returned.
Establishes two-way data binding between an attribute and this **LocalStorage** instance.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ----------- |
| propName | string | Yes | Name of the target attribute.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------------- |
| propName | string | Yes | Attribute name in AppStorage.|
| @Link | Returns two-way binding to this attribute if there is data with a given key. This means that attribute changes made by a variable or component will be synchronized to the **AppStorage**, and attribute changes made through the **AppStorage** will be synchronized to the variable or component.|
Works in a way similar to the **Link** API. If the current key is stored in the **AppStorage**, the value corresponding to the key is returned. If the key has not been created, a **Link** instance corresponding to the default value is created and returned.
Works in a way similar to the **Link** API. If the given attribute exists in AppStorage, the two-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist, it is created and initialized with <bclass="+ topic/ph hi-d/b "id="b537113298389">defaultValue</b> in AppStorage, and two-way bound data is returned.
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | ----------- |
| propName | string | Yes | Target key.|
| defaultValue | T | Yes | Default value to set. |
| @Link | Returns the value corresponding to the key if the current key is stored in the **AppStorage**; creates and returns a **Link** instance corresponding to the default value if the key has not been created.|
| SubscribedAbstractProperty<T> | Instance of **SubscribedAbstractProperty<T>** and two-way bound data of the given attribute in AppStorage|
Establishes one-way data binding with the given attribute (specified by **propName**) in AppStorage. If the given attribute exists in AppStorage, the one-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist in AppStorage, **undefined** is returned. Updates of the one-way bound data are not synchronized back to AppStorage.
>**NOTE**
>
>Prop supports only simple types.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ----------- |
| propName | string | Yes | Target key.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------------- |
| propName | string | Yes | Attribute name in AppStorage.|
Works in a way similar to the **Prop** API. If the given attribute exists in AppStorage, the one-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist, it is created and initialized with **defaultValue** in AppStorage, and one-way bound data is returned.
| boolean | Returns **true** if the operation is successful; return **false** if the attribute with the specified attribute name does not exist in AppStorage, or the value to set is **undefined** or **null**. |
Sets a new value for the attribute with the specified attribute name in AppStorage or, if the attribute does not exist, creates one with the specified attribute name and default value.
| propName | string | Yes | Attribute name in AppStorage. |
| newValue | T | Yes | Attribute value, which cannot be **undefined** or **null**.|
```ts
AppStorage.setOrCreate('simpleProp',121);
```
### delete<sup>10+</sup>
static delete(propName: string): boolean
Deletes the attribute with the specified attribute name from AppStorage
under the prerequisite that the attribute does not have a subscriber. If there is a subscriber, **false** is returned. If the deletion is successful, **true** is returned.
The subscribers of the attribute are attributes with the same name bound to APIs such as **Link** and **Prop**, **\@StorageLink('propName')**, and **\@StorageProp('propName')**. This means that if **\@StorageLink('propName')** and **\@StorageProp('propName')** are used in a custom component or if there is still a **SubscribedAbstractProperty** instance in sync with the attribute, the attribute cannot be deleted from AppStorage.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------------- |
| propName | string | Yes | Attribute name in AppStorage.|
Deletes all attributes from AppStorage under the prerequisite that none of the attributes has a subscriber. If any of the attributes has a subscriber, **false** is returned. If the deletion is successful, **true** is returned.
For details about the subscriber, see [Delete](#delete10).
| @Prop | Returns one-way binding to an attribute with a given key if the attribute exists; returns **undefined** otherwise. One-way binding means that attribute changes made through the **AppStorage** will be synchronized to the variable or component, but attribute changes made by the variable or component will not be synchronized to the **AppStorage**. This API returns immutable variables and is applicable to mutable and immutable state variables alike.|
Establishes two-way data binding with the given attribute (specified by **propName**) in AppStorage. If the given attribute exists in AppStorage, the two-way bound data of the attribute in AppStorage is returned.
Any update of the data is synchronized back to AppStorage, which then synchronizes the update to all data and custom components bound to the attribute.
If the given attribute does not exist in AppStorage, **undefined** is returned.
This API is deprecated since API version 10. You are advised to use [link10+](#link10) instead.
Works in a way similar to the **Prop** API. If the current key is stored in the **AppStorage**, the value corresponding to the key is returned. If the key has not been created, a **Prop** instance corresponding to the default value is created and returned.
| @Prop | Returns the value corresponding to the key if the current key is stored in the **AppStorage**; creates and returns a **Prop** instance corresponding to the default value otherwise.|
Works in a way similar to the **Link** API. If the given attribute exists in AppStorage, the two-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist, it is created and initialized with <bclass="+ topic/ph hi-d/b "id="b537113298389">defaultValue</b> in AppStorage, and two-way bound data is returned.
Checks whether the attribute corresponding to the specified key exists.
This API is deprecated since API version 10. You are advised to use [setAndLink10+](#setandlink10) instead.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------- |
| propName | string | Yes | Key of the attribute.|
| SubscribedAbstractProperty<T> | Instance of **SubscribedAbstractProperty<T>** and two-way bound data of the given attribute in AppStorage|
Establishes one-way data binding with the given attribute (specified by **propName**) in AppStorage. If the given attribute exists in AppStorage, the one-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist in AppStorage, **undefined** is returned. Updates of the one-way bound data are not synchronized back to AppStorage.
Obtains the value of the specified key.
>**NOTE**
>
>Prop supports only simple types.
>
>This API is deprecated since API version 10. You are advised to use [prop10+](#prop10) instead.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ----------- |
| propName | string | Yes | Key of the value to obtain.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------------- |
| propName | string | Yes | Attribute name in AppStorage.|
**Return value**
| Type | Description |
| ----------------- | ------------- |
| T or undefined| Returns the attribute value if the attribute exists; returns **undefined** otherwise.|
Works in a way similar to the **Prop** API. If the given attribute exists in AppStorage, the one-way bound data of the attribute in AppStorage is returned. If the given attribute does not exist, it is created and initialized with **defaultValue** in AppStorage, and one-way bound data is returned.
This API is deprecated since API version 10. You are advised to use [setAndProp10+](#setandprop10) instead.
| boolean | Updates the value of the attribute and returns **true** if an attribute that has the same name as the specified key exists; creates an attribute with the specified value as its default value and returns **false** otherwise. **undefined** and **null** are not allowed to return **true**.|
| boolean | Returns **true** if the attribute with the specified attribute name exists in AppStorage; returns **false** otherwise.|
| boolean | Returns **true** if the key-value pair exists and is successfully deleted; returns **false** otherwise.|
| boolean | Returns **true** if the operation is successful; return **false** if the attribute with the specified attribute name does not exist in AppStorage, or the value to set is **undefined** or **null**. |
Sets a new value for the attribute with the specified attribute name in AppStorage or, if the attribute does not exist, creates one with the specified attribute name and default value.
This API is deprecated since API version 10. You are advised to use [setOrCreate10+](#setorcreate10) instead.
| propName | string | Yes | Attribute name in AppStorage. |
| newValue | T | Yes | Attribute value, which cannot be **undefined** or **null**.|
```ts
AppStorage.SetOrCreate('simpleProp',121);
```
### Delete<sup>(deprecated)</sup>
static Delete(propName: string): boolean
Deletes the attribute with the specified attribute name from AppStorage
under the prerequisite that the attribute does not have a subscriber. If there is a subscriber, **false** is returned. If the deletion is successful, **true** is returned.
The subscribers of the attribute are attributes with the same name bound to APIs such as **Link** and **Prop**, **\@StorageLink('propName')**, and **\@StorageProp('propName')**. This means that if **\@StorageLink('propName')** and **\@StorageProp('propName')** are used in a custom component or if there is still a **SubscribedAbstractProperty** instance in sync with the attribute, the attribute cannot be deleted from AppStorage.
This API is deprecated since API version 10. You are advised to use [delete10+](#delete10) instead.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------------- |
| propName | string | Yes | Attribute name in AppStorage.|
**Return value**
| Type | Description |
| -------------- | -------------- |
| array\<string> | Returns an array of strings containing all keys.|
This API is deprecated since API version 9. You are advised to use [Clear9+](#clear9) instead.
**Return value**
| Type | Description |
| ------- | --------------------------------- |
| boolean | Returns **true** if all attributes are deleted; returns **false** if any of the attributes is being referenced by a state variable.|
```ts
letsimple=AppStorage.Clear()
letsimple=AppStorage.staticClear();
```
### Clear<sup>(deprecated)</sup>
static Clear(): boolean
Deletes all attributes from AppStorage under the prerequisite that none of the attributes has a subscriber. If any of the attributes has a subscriber, **false** is returned. If the deletion is successful, **true** is returned.
For details about the subscriber, see [Delete](#deletedeprecated).
This API is deprecated since API version 10. You are advised to use [clear10+](#clear10) instead.
For details about how to use **getShared**, see [Sharing a LocalStorage Instance from UIAbility to One or More Pages](../../quick-start/arkts-localstorage.md#sharing-a-localstorage-instance-from-uiability-to-one-or-more-pages).
```ts
letstorage=LocalStorage.GetShared()
```
### has<sup>9+</sup>
has(propName: string): boolean
Checks whether the **LocalStorage** contains the specified attribute.
Checks whether the attribute with the specified attribute name exists in LocalStorage.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------- |
| propName | string | Yes | Key of the attribute.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------ |
| propName | string | Yes | Attribute name in LocalStorage.|
**Return value**
| Type | Description |
| ------- | ------------- |
| boolean | Returns whether the attribute exists.|
| boolean | Returns **true** if the operation is successful; return **false** if the attribute with the specified attribute name does not exist in LocalStorage, or the value to set is **undefined** or **null**. |
Creates or updates the value of the specified key.
Sets a new value for the attribute with the specified attribute name in LocalStorage or, if the attribute does not exist, creates one with the specified attribute name and default value.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | :--- | -------------- |
| propName | string | Yes | Key of the value to create or update. |
| newValue | T | Yes | Value to be updated or created.|
| boolean | Updates the value of the attribute and returns **true** if an attribute that has the same name as the specified key exists; creates an attribute with the specified value as its default value and returns false otherwise. **undefined** and **null** are not allowed.|
| boolean | Returns **false** if **newValue** is set to **undefined** or **null**.<br>Updates the target attribute with the new value and returns **true** if the attribute exists in LocalStorage.<br>Creates an attribute with the specified attribute name and default value if the attribute does not exist in LocalStorage.|
Establishes two-way data binding with the given attribute in this **LocalStorage** instance. If the given attribute exists, the two-way bound data of the attribute in LocalStorage is returned.
Establishes two-way data binding between an attribute and this **LocalStorage** instance.
Any update of the data is synchronized back to LocalStorage, which then synchronizes the update to all data and custom components bound to the attribute.
If the given attribute does not exist in LocalStorage, **undefined** is returned.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ----------- |
| propName | string | Yes | Name of the target attribute.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------ |
| propName | string | Yes | Attribute name in LocalStorage.|
| T | Returns two-way binding to this attribute if there is data with a given key. This means that attribute changes made by a variable or component will be synchronized to the **LocalStorage**, and attribute changes made through the **LocalStorage** will be synchronized to the variable or component. returns **undefined** if the attribute with the given key does not exist.|
| SubscribedAbstractProperty<T> | Returns the **SubscribedAbstractProperty<T>** instance if the given attribute exists in AppStorage; returns **undefined** otherwise.|
Works in a way similar to the **Link** API. If the given attribute exists in LocalStorage, the two-way bound data of the attribute in LocalStorage is returned. If the given attribute does not exist, it is created and initialized with **defaultValue** in LocalStorage, and two-way bound data is returned.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | ----------- |
| propName | string | Yes | Target key.|
| defaultValue | T | Yes | Default value to set. |
| @Link | Returns the value corresponding to the key if the current key is stored in the **LocalStorage**; creates and returns a **Link** instance corresponding to the default value if the key has not been created.|
| SubscribedAbstractProperty<T> | Returns the **SubscribedAbstractProperty<T>** instance if the given attribute exists in AppStorage; returns **undefined** otherwise.|
Establishes one-way data binding with the given attribute in this **LocalStorage** instance. If the given attribute exists, the one-way bound data of the attribute in LocalStorage is returned. If the given attribute does not exist in LocalStorage, **undefined** is returned. Updates of the one-way bound data are not synchronized back to LocalStorage.
Establishes one-way data binding with an attribute to update its status.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------- |
| propName | string | Yes | Key of the attribute.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------ |
| propName | string | Yes | Attribute name in LocalStorage.|
| @Prop | Returns one-way binding to an attribute with a given key if the attribute exists; returns **undefined** otherwise. One-way binding means that attribute changes made through the **LocalStorage** will be synchronized to the variable or component, but attribute changes made by the variable or component will not be synchronized to the **LocalStorage**. This API returns immutable variables and is applicable to mutable and immutable state variables alike. |
| SubscribedAbstractProperty<S> | Returns the **SubscribedAbstractProperty<S>** instance if the given attribute exists in LocalStorage; returns **undefined** otherwise.|
Establishes one-way data binding with the given attribute in this **LocalStorage** instance. If the given attribute exists, the one-way bound data of the attribute in LocalStorage is returned. If the given attribute does not exist, it is created and initialized with **defaultValue** in LocalStorage, and one-way bound data is returned.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | -------------- |
| propName | string | Yes | Key of the target key-value pair.|
| defaultValue | T | Yes | Default value to set. |
| @Prop | Returns the value corresponding to the given key if the key is stored in the **LocalStorage**; creates and returns a **Prop** instance corresponding to the default value if the key has not been created.|
| SubscribedAbstractProperty<S> | Instance of **SubscribedAbstractProperty<T>** and one-way bound data of the given attribute in LocalStorage.|
Deletes the key-value pair that matches the specified key.
Deletes the attribute with the specified attribute name from LocalStorage under the prerequisite that the attribute does not have a subscriber. If the deletion is successful, **true** is returned.
The subscribers of the attribute are attributes with the same name bound to the **Link** and **Prop** APIs, **\@LocalStorageLink('propName')**, and **\@LocalStorageProp('propName')**. This means that if **\@LocalStorageLink('propName')** and **\@LocalStorageProp('propName')** are used in a custom component or if there is still a **SubscribedAbstractProperty** instance (return type of the **link** and **prop** APIs) in sync with the attribute, the attribute cannot be deleted from LocalStorage.
Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | :--- | ------------ |
| propName | string | Yes | Key of the target key-value pair.|
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------ |
| propName | string | Yes | Attribute name in LocalStorage.|
Deletes all attributes from LocalStorage under the prerequisite that none of the attributes has a subscriber. If any of the attributes has a subscriber, **false** is returned. If the deletion is successful, **true** is returned.
Since API version 9, this API is supported in ArkTS widgets.
**Return value**
| Type | Description |
| ------- | --------------------------------- |
| boolean | Returns **true** if all attributes are deleted; returns **false** if any of the attributes is being referenced by a state variable.|
For details about how to use PersistentStorage on the UI, see [PersistentStorage: Application State Persistence](../../quick-start/arkts-persiststorage.md).
| defaultValue | number\|string\|boolean | Yes | Default value used to initialize the created attribute. The value cannot be **undefined** or **null**.|
Persists the attribute with the specified key in AppStorage to a file. This API is usually called before access to AppStorage.
The sequence of determining the type and value of an attribute is as follows:
1. If the PersistentStorage file contains the attribute with the specified key, an attribute with the key as the name is created in AppStorage and initialized with the attribute of the key found in PersistentStorage.
2. If the attribute with the specified key is not found in the PersistentStorage file, AppStorage is searched for the attribute corresponding to the key. If the matching attribute is found, it is persisted.
3. If no matching attribute is found in AppStorage, it is created in AppStorage, initialized with the value of **defaultValue**, and persisted.
Creates a **persistentstorage** object.
According to the preceding initialization process, if AppStorage contains the matching attribute, the value of this attribute is used to overwrite the value in the PersistentStorage file. Because AppStorage stores data in the memory, the attribute value becomes impersistent.
| defaultValue | T | Yes | Default value used to initialize the created attribute. The value cannot be **undefined** or **null**.|
**Example:**
For details about how to use persistProp, see [Accessing PersistentStorage Initialized Attribute from AppStorage](../../quick-start/arkts-persiststorage.md#accessing-persistentstorage-initialized-attribute-from-appstorage).
### deleteProp<sup>10+</sup>
static deleteProp(key: string): void
Performs the reverse operation of **PersistProp**. Specifically, this API deletes the attribute corresponding to the key from PersistentStorage. Subsequent AppStorage operations do not affect data in PersistentStorage.
Works in a way similar to the **PersistProp** API, with the difference that it allows for persistence in batches and is therefore ideal for initialization during application startup.
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | -------------- |
| key | string | Yes | Key of the target attribute. |
| defaultValue | T | Yes | Value of the target attribute.|
Persists the attribute with the specified key in AppStorage to a file. This API is usually called before access to AppStorage.
The sequence of determining the type and value of an attribute is as follows:
1. If the PersistentStorage file contains the attribute with the specified key, an attribute with the key as the name is created in AppStorage and initialized with the attribute of the key found in PersistentStorage.
2. If the attribute with the specified key is not found in the PersistentStorage file, AppStorage is searched for the attribute corresponding to the key. If the matching attribute is found, it is persisted.
3. If no matching attribute is found in AppStorage, it is created in AppStorage, initialized with the value of **defaultValue**, and persisted.
According to the preceding initialization process, if AppStorage contains the matching attribute, the value of this attribute is used to overwrite the value in the PersistentStorage file. Because AppStorage stores data in the memory, the attribute value becomes impersistent.
Cancels two-way binding. The value of this attribute will be deleted from the persistent storage.
This API is deprecated since API version 10. You are advised to use [persistProp10+](#persistprop10) instead.
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ |
| key | string | Yes | Key of the target attribute.|
Changes the attributes that match the specified keys to persistent data in the **AppStorage**.
Performs the reverse operation of **PersistProp**. Specifically, this API deletes the attribute corresponding to the key from PersistentStorage. Subsequent AppStorage operations do not affect data in PersistentStorage.
This API is deprecated since API version 10. You are advised to use [deleteProp10+](#deleteprop10) instead.
Works in a way similar to the **PersistProp** API, with the difference that it allows for persistence in batches and is therefore ideal for initialization during application startup.
This API is deprecated since API version 10. You are advised to use [persistProps10+](#persistprops10) instead.
| properties | {key: string, defaultValue: any}[] | Yes | Array of attributes to persist.<br>**key**: attribute name.<br>**defaultValue**: default value. The rules are the same as those of **PersistProp**.|
| key | string | Yes | Environment variable name. For details about the value range, see [Built-in Environment Variables](#built-in-environment-variables).|
| defaultValue | number\|string\|boolean | Yes | Default value used if the value of the environment variable key is not found in AppStorage.|
Saves the built-in environment variable key in environment to AppStorage. If the value of the environment variable key is not found in AppStorage, the default value is used. If the value is successfully saved, **true** is returned. If the value of the environment variable key is found in AppStorage, **false** is returned.
You are advised to call this API when the application is started.
It is incorrect to use AppStorage to read environment variables without invoking **EnvProp**.
| key | string | Yes | Environment variable name. For details about the value range, see [Built-in Environment Variables](#built-in-environment-variables). |
| value | S | Yes | Default value used if the value of the environment variable key is not found in AppStorage.|
| boolean | Returns **false** if the attribute corresponding to the key exists in AppStorage; returns **false** otherwise.|
**Example:**
For details about how to use **envProp**, see [Accessing Environment Parameters from UI](../../quick-start/arkts-environment.md#accessing-environment-parameters-from-ui).
### envProps<sup>10+</sup>
static envProps(props: EnvPropsOptions[]): void
Works in a way similar to the **EnvProp** API, with the difference that it allows for initialization of multiple attributes in batches. You are advised to call this API during application startup to save system environment variables to AppStorage in batches.
Saves the built-in environment variable key in environment to AppStorage. If the value of the environment variable key is not found in AppStorage, the default value is used. If the value is successfully saved, **true** is returned. If the value of the environment variable key is found in AppStorage, **false** is returned.
You are advised to call this API when the application is started.
Binds this system attribute to the **AppStorage**. You are advised to use this API during application startup. If the attribute already exists in the **AppStorage**, **false** is returned. Do not use the variables in the **AppStorage**. Instead, call this API to bind environment variables.
It is incorrect to use AppStorage to read environment variables without invoking **EnvProp**.
This API is deprecated since API version 10. You are advised to use [envProp10+](#envprop10) instead.
**Parameters**
| Name | Type | Mandatory | Description | Description |
| key | string | Yes | Environment variable name. For details about the value range, see [Built-in Environment Variables](#built-in-environment-variables). |
| value | S | Yes | Default value used if the value of the environment variable key is not found in AppStorage.|
**Return value**
| Type | Description |
| ------- | ---------------------- |
| boolean | Returns whether the attribute exists in the **AppStorage**.|
| accessibilityEnabled | string | Whether to enable accessibility. |
| colorMode | ColorMode | Color mode. The options are as follows:<br>- **ColorMode.LIGHT**: light mode.<br>- **ColorMode.DARK**: dark mode.|
| fontScale | number | Font scale. |
| fontWeightScale | number | Font weight scale. |
| layoutDirection | LayoutDirection | Layout direction. The options are as follows:<br>- **LayoutDirection.LTR**: The direction is from left to right.<br>- **LayoutDirection.RTL**: The direction is from right to left.|
| languageCode | string | Current system language. The value is in lowercase, for example, **zh**. |
Works in a way similar to the **EnvProp** API, with the difference that it allows for initialization of multiple attributes in batches. You are advised to call this API during application startup to save system environment variables to AppStorage in batches.
Associates this system item array with the **AppStorage**.
This API is deprecated since API version 10. You are advised to use [envProps10+](#envprops10) instead.
**Parameters**
| Name | Type | Mandatory | Description | Description |
| accessibilityEnabled | string | Whether to enable accessibility. |
| colorMode | ColorMode | Color mode. The options are as follows:<br>- **ColorMode.LIGHT**: light mode.<br>- **ColorMode.DARK**: dark mode.|
| fontScale | number | Font scale. |
| fontWeightScale | number | Font weight scale. |
| layoutDirection | LayoutDirection | Layout direction. The options are as follows:<br>- **LayoutDirection.LTR**: from left to right.<br>- **LayoutDirection.RTL**: from right to left.|
| languageCode | string | Current system language. The value is in lowercase, for example, **zh**. |