HarmonyOSBaseLibs/src/main/ets/utils/AppStorageHelper.ets
2024-09-24 17:50:53 +08:00

22 行
418 B
Plaintext

/**
* 永久化存储,存储在本地文件
*/
export class AppStorageHelper {
/**
* 缓存string
* @param key
* @param value
*/
public static save<T>(key: string, value: T|undefined) {
PersistentStorage.persistProp(key, value)
}
/**
* 获取已缓存的string
* @param key
* @returns
*/
public static get<T>(key: string):T|undefined {
return AppStorage.get<T>(key)
}
}