This commit is contained in:
parent
f3e6aae9c3
commit
a6cd238330
|
|
@ -34,11 +34,13 @@ class UpdateManager(private val context: Context) {
|
||||||
private val fileName = "StandApp_Update.apk"
|
private val fileName = "StandApp_Update.apk"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取应用缓存目录下的临时文件 URI,避免申请外部存储权限
|
* 获取应用外部专属下载目录下的文件 URI,避免申请外部存储权限的同时确保安装包能被系统安装器读取
|
||||||
*/
|
*/
|
||||||
private fun getCacheFileUri(): Uri {
|
private fun getCacheFileUri(): Uri {
|
||||||
val cacheDir = context.externalCacheDir ?: context.cacheDir
|
val dir = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
|
||||||
val file = File(cacheDir, fileName)
|
?: context.externalCacheDir
|
||||||
|
?: context.cacheDir
|
||||||
|
val file = File(dir, fileName)
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.delete()
|
file.delete()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue