我遇到了以下问题:
打开失败:
EACCES(Permission denied)
出错在这一行:OutputStream myOutput = new FileOutputStream(outFileName);
我已经检查了root权限,并尝试添加了 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 streams
myOutput.flush();
myOutput.close();
myInput.close();
buffer = null;
outFileName = null;
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}