Tag: android fileprovider

getExternalFilesDir返回不一致的目录

我有一个操作,允许用户下载图像,并将其保存到我的应用程序的数据目录。 我创建临时文件,如下所示: @Throws(IOException::class) fun Context.createPrivateMediaFile(prefix: String, extension: String): File { val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) val imageFileName = "${prefix}_${timeStamp}_" val storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES) return File.createTempFile(imageFileName, extension, storageDir) } 我就这样使用它: try { photoFile = createPrivateMediaFile(".png") } catch (e: IOException) { errorRef = e } finally { if (photoFile == null) { callback(null) } else { tempFilePath […]