我理解这个问题非常相似:What is the difference between getDir and getFilesDir on Android?
但是,当我只想将我的文件保存在我的私有(private)数据中时,我仍然不确定该使用什么。
对于一个目录,我应该只使用 data/data/com.test.myapp
吗?这将使它对我的应用程序私有(private)?
// Gets the absolute path to the filesystem directory where your internal files are saved.
getFilesDir()
// Creates (or opens an existing) directory within your internal storage space.
getDir()
我也尝试通读一些通用软件开源项目,但我想我只是对整个 getExternalFilesDir()
感到更加困惑,因为 Android 不引用内部存储(非 SD 卡)作为特定 API 级别后的“外部”存储?
最佳答案
I'm still not sure what to use when I simply want to save my files in my private data
getFilesDir()
会很好地工作。
For a directory should I just use data/data/com.test.myapp?
永远不要对目录进行硬编码。
That will make it private to my application?
getFilesDir()
对您的应用程序是私有(private)的(异常(exception):已 root 其设备并以 super 用户权限运行应用程序的用户)
我不知道 getDir()
有什么好的用途,我不推荐它。
because doesn't Android refer to internal storage (non-sdcard) as "external" storage after a certain api level?
外部存储在 Android 1.0 之前就已经存在。
内部存储大致意味着“对您的应用私有(private)”(除非您采取特定步骤使其非私有(private))。外部存储大致意味着“对用户和其他应用可见”。
在a book that I know that you own :-),您将在“ Assets 、文件和数据解析”一章中找到有关内部和外部存储的更多详细信息。
关于java - Android getFilesDir() 与 getDir() - 我用什么将文件保存在我的应用程序私有(private)数据中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18237859/