我想将我的应用程序所需的文件保存在内部存储下的一个目录中。在前一阶段,我使用 externalStorageDirectory 来存储我的数据。 现在我使用下面的代码来引用我的外部目录
Environment.getExternalStorageDirectory()+"/mydirectory";
我需要一个等效的代码来引用我在内部目录中的目录,任何人都可以帮助我...谢谢,
解决方案:
getFilesDir()+"/mydirectory";
感谢您的所有建议和帮助。
最佳答案
为此使用 getFilesDir()
。
来自docs :
Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.
No permissions are required to read or write to the returned path, since this path is internal storage.
为了回答您的评论,我将引用文档 docs :
By default, files saved to the internal storage are private to your application and other applications cannot access them (and the user only can access as root). When the user uninstalls your application, these files are removed.
关于android - android内部存储中目录的绝对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25905649/