保存到缓存目录的文件总是 MODE_PRIVATE?

Files saved to Cache dir are always MODE_PRIVATE?

保存到内部存储有两个选项:

  1. files 目录,这是一个持久性文件夹,当存储 space 不足时,不会 删除该文件夹:

    outputStream = openFileOutput(文件名, Context.MODE_PRIVATE); outputStream.write(string.getBytes()); outputStream.close();

  2. 缓存目录,这是一个持久性文件夹,当存储空间 space 不足时, 将其删除:

    file = File.createTempFile(fileName, null, context.getCacheDir());

我的问题: 保存到缓存目录的文件是否会像文件目录中的 MODE_PRIVATE 一样? 意思是 - 它们只能由我的应用程序访问,还是其他应用程序也可以访问这些文件?

Will files saved to the cache dir act like the MODE_PRIVATE in the files dir?

是的。

will they be accessible only to my app

是的。

or will other apps also be able to access the files?

否,除非您通过其他方式提供访问权限,例如流式传输 ContentProvider