AppStorageHelper.ets 427 B

12345678910111213141516171819202122
  1. /**
  2. * 永久化存储,存储在本地文件
  3. */
  4. export class AppStorageHelper {
  5. /**
  6. * 缓存string
  7. * @param key
  8. * @param value
  9. */
  10. public static save(key: string, value: string|undefined) {
  11. PersistentStorage.persistProp(key, value)
  12. }
  13. /**
  14. * 获取已缓存的string
  15. * @param key
  16. * @returns
  17. */
  18. public static get(key: string):string|undefined {
  19. return AppStorage.get<string>(key)
  20. }
  21. }