我正进入(状态
开放失败:
EACCES (Permission denied)
在线上 OutputStream myOutput = new FileOutputStream(outFileName);
我检查了根,我试过了android.permission.WRITE_EXTERNAL_STORAGE.
我该如何解决这个问题?
try {
InputStream myInput;
myInput = getAssets().open("XXX.db");
// Path to the just created empty db
String outFileName = "/data/data/XX/databases/"
+ "XXX.db";
// Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
// Transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
// Close the …Run Code Online (Sandbox Code Playgroud) android android-permissions android-5.0-lollipop android-storage
我希望我的应用程序将应用程序DB存档到SD卡.在我的代码中,我检查目录是否canWrite()存在,如果不存在,则抛出一个IOException.在这个特定的实例中,我试图将db文件复制到SD卡上的根目录,但它正在抛出一个IOException.如何更改文件夹/文件的权限才能写入?