[英]Unable to write to specified path in internal storage in android
我正在尝试在我的Android应用程序中写入内部存储中的特定路径:/ data / somefolder,但出现错误java.io.filenotfoundexception:权限被拒绝
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是否仅将文件创建限制为/ data / data / package / files之类的特定包?
我尝试使用FileOutputStream并成功在/ data / data / package / files中创建了文件。
我认为您不能只写入数据目录。 那将需要root访问。 您可以使用应用程序的内部存储或外部存储(SD卡)。 请在这里查看工作原理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.