[英]Unable to write to specified path in internal storage in android
I am trying to write to a specific path in internal storage in my android app :/data/somefolder but I get the error java.io.filenotfoundexception : Permission denied 我正在尝试在我的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();
}
My question is : Is it even possible to write into this folder in android internal storage or does android restrict file creation only to the specific package like /data/data/package/files ? 我的问题是:是否有可能将其写入android内部存储中的此文件夹中,或者android是否仅将文件创建限制为/ data / data / package / files之类的特定包?
I tried using FileOutputStream and the file got created successfully in /data/data/package/files. 我尝试使用FileOutputStream并成功在/ data / data / package / files中创建了文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.