本地存储Storages
@liouyang25 翻了下源码,并没发现什么类似列出已经存在的本地存储的方法,自己写了一个,可以列出通过 storages 创建的所有本地存储文件路径,autojs.localstorage. 后面接的就是存储名,要删除的话用 files.remove(path) 就行
function getExistedLocalStorageFilesPathArr() {
let localStorageFilePathArr = [];
let filesDir = context.getFilesDir().toString()
let localStoragePath = filesDir.slice(0, filesDir.lastIndexOf("/")) + "/shared_prefs/"
if (files.isDir(localStoragePath)) {
let fileNameList = files.listDir(localStoragePath, (str) => { return str.startsWith("autojs.localstorage.") && str.endsWith(".xml")});
if (fileNameList.length > 0) {
for (let fileName of fileNameList) {
localStorageFilePathArr.push(localStoragePath + fileName);
}
}
}
return localStorageFilePathArr;
}