战力不足五
战力不足五
  • 发布:2023-10-24 21:40
  • 更新:2023-10-28 11:31
  • 阅读:770

targetSdkVersion设置为30以上文件无法存储到指定目录

分类:uni-app

这是代码 在设置targetSdkVersion为30之前是可以存储到指定的文件路径的。
设置之后他就变成了在当前APP安装的目录下面强行创建了如下地址。而不是存储到根目录指定的路径应该怎么解决
我通过配置requestLegacyExternalStorage=true甚至追加了<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> 都不好使在安卓11已经以上版本就彻底失去了我保存文件到指定目录的功能了。应该怎么办啊,而且targetSdkVersion这玩意只能升不能降.....

const times = new Date().getTime()
if(typeValue == 'bd') filename = file://storage/emulated/0/baidu/ime/skins/${times}.bds;//百度
if(typeValue == 'sogou') filename = file://storage/emulated/0/sogou/sga/wallpaper/${times}.ssf;//搜狗
plus.downloader.createDownload(file,{
filename
},async (d,status)=>{
this.uiwu.hideloading()
if(status == 200){
// this.uiwu.toast(已保存到文件夹:${filename})
const dd = await this.uiwu.model({
title:'温馨提示',
content:皮肤已下载完成是否前去使用?,
showCancel:true
})
if(dd){
plus.runtime.launchApplication({
pname: typeValue == 'bd' ? 'com.baidu.input' : 'com.sohu.inputmethod.sogou'
})
}
}else{
this.uiwu.toast('下载失败,请重试')
}
}).start()

2023-10-24 21:40 负责人:无 分享
已邀请:
战力不足五

战力不足五 (作者) - .......

有没有人支个招啊

DCloud_Android_ST

DCloud_Android_ST

targetSdkVersion=30 requestLegacyExternalStorage 会失效 如果你需要使用系统完整路径需要申请权限 MANAGE_EXTERNAL_STORAGE 你可以查下相关资料

要回复问题请先登录注册