赞
踩
使用的是mmkv
ohpm install @ohos/mmkv
import{MMKV, SerializeBase} from '@ohos/mmkv' /** * 数据存储工具类 */ class MMKVUtil{ private filePath:string = '' private cachePath:string = '' private mmkv:MMKV private mmapID:string="MMKV" constructor() { this.filePath = globalThis.filesDir this.cachePath = globalThis.cacheDir let backupRootDir=this.filePath+"/mmkv_backup" MMKV.initialize(this.filePath+"/mmvk",this.cachePath) this.mmkv= MMKV.getBackedUpMMKVWithID(this.mmapID,MMKV.SINGLE_PROCESS_MODE,this.mmapID,backupRootDir) } /** * 存储数据:string * @param key * @param value */ saveString(key:string,value:string){ this.mmkv.encode(key,value) } /** * 获取数据:boolean * @param key * @returns */ getString(ke
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。