Mert Mert - 4 months ago 33
Android Question

Exception 'open failed: EACCES (Permission denied)' on Android

I am getting

open failed:
EACCES (Permission denied)

on the line
OutputStream myOutput = new FileOutputStream(outFileName);

I checked the root, and I tried

How can I fix this problem?

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 = > 0) {
myOutput.write(buffer, 0, length);

// Close the streams
buffer = null;
outFileName = null;
catch (IOException e1) {
// TODO Auto-generated catch block


I had the same problem... The <uses-permission was in the wrong place. This is right:

        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>





The uses-permission tag needs to be outside the application tag.