由于Android文档中描述的那样,创建将在位于应用程序的目录存在的方法,在新的文件Context类:openFileOutput().
但是如果我使用类中的简单createNewFile()方法,文件位于何处File.?
Dom*_*ohr 33
CreateNewFile()使用如下:
File file = new File("data/data/your package name/test.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
因此,您将告诉文件应在何处创建它.请记住,您只能在包装上创建新文件.那就是"数据/数据/你的包名/".
| 归档时间: |
|
| 查看次数: |
32397 次 |
| 最近记录: |