【发布时间】:2018-04-22 20:56:49
【问题描述】:
所以我使用了一个图像捕获库,它为我提供了一个临时缓存文件的 URI。然后我想将该文件保存在我的应用程序的文件目录中作为“/avatar.jpg”,覆盖任何现有的“avatar.jpg”文件。到目前为止,这是我尝试实现目标的代码:
File file = new File(tempImagePath);
File avatarFile = new File(getFilesDir(), "avatar.jpg");
file.renameTo(avatarFile);
但是,这不会覆盖任何现有的“avatar.jpg”文件。我注意到文件系统 API 发生了一些变化,例如引入了 FileProvider,所以我不是完成我需要的最快/最有效的方法。
【问题讨论】:
标签: java android database performance filesystems