# PersistentStorage **PersistentStorage** is used to manage persistent data of applications. This object can link the persistent data of a specific tag to the **AppStorage** and access the persistent data through the **AppStorage** APIs or access the variable of the corresponding key through the **@StorageLink** decorator. ## PersistentStorage APIs

Name

Type

Return Value

Definition

PersistProp

key : string

defaultValue: T

void

The associated named attribute becomes persistent data in the AppStorage. Value overwriting sequence:

If the attribute exists in the AppStorage, copy the data in Persistent to the attribute value in the AppStorage.

If Persistent contains the specified attribute, use the attribute value in Persistent.

If the preceding conditions are not met, defaultValue is used. The null and undefined values are not supported.

DeleteProp

key: string

void

Cancels bidirectional data binding. The value of this attribute is deleted from the persistent storage.

PersistProps

keys: {

key: string,

defaultValue: any

}[]

void

Associates multiple named attribute bindings.

Keys

void

Array<string>

Returns the flags of all persistent attributes.

>![](../../public_sys-resources/icon-note.gif) **NOTE:** >- When using **PersistProp**, ensure that the input key exists in the **Appstorage**. >- **DeleteProp** takes effect only for the data that has been linked during the current startup. ``` PersistentStorage.PersistProp("highScore", "0"); @Entry @Component struct PersistentComponent { @StorageLink('highScore') highScore: string = '0' @State currentScore: number = 0 build() { Column() { if (this.currentScore === Number(this.highScore)) { Text(`new highScore : ${this.highScore}`) } Button() { Text(`goal!, currentScore : ${this.currentScore}`) .fontSize(10) }.onClick(() => { this.currentScore++ if (this.currentScore > Number(this.highScore)) { this.highScore = this.currentScore.toString() } }) } } } ```