【发布时间】:2014-08-20 06:10:22
【问题描述】:
我正在尝试在我的 android 应用程序中写入内部存储中的特定路径:/data/somefolder 但我收到错误 java.io.filenotfoundexception : Permission denied
String testString="Hello World!";
File newFile=new File("/data/somefolder/testFile.txt");
try{
OutputStream myOut=new BufferedOutputStream(new FileOutputStream(newFile,true));
myOut.write(testString.getBytes());
myOut.flush();
myOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我的问题是:是否甚至可以在 android 内部存储中写入此文件夹,或者 android 是否仅将文件创建限制为特定包,例如 /数据/数据/包/文件?
我尝试使用 FileOutputStream 并在 /data/data/package/files 中成功创建了文件。
【问题讨论】: