Read file in android - file permission denied

android, filesystems

Solution

Make sure you have added the permission to read external storage in your manifest file.

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

Problem

I want to read file from external storage. I uploaded the file in Eclipse DDMS to storage/sdcard (image below). But whenever I tried to read, I got an error of permission denied. Is there any problem in my file permission? Or I need to add anything in manifest file (I am not writing anything at the moment)? Any help will be appreciated. Code: ``` public void extimport(View v){ EditText xedittxt = (EditText) findViewById(R.id.frmexttxt); String xedit = xedittxt.getText().toString(); xedit = xedit.trim(); File file; file = new File(xedit); StringBuilder text = new StringBuilder(); Log.d("fcheck",""+xedit); try { BufferedReader br = new BufferedReader(new FileReader(file)); //THIS LINE THROWS ERROR Log.d("fcheck","f3"); //This line never got printed String line; while ((line = br.readLine()) != null) { text.append(line); text.append('\n'); } br.close(); resultView = (TextView) findViewById(R.id.header); resultView.setText(text); } catch (IOException e) { Log.d("File open error",""+e); Toast.makeText(getApplicationContext(), "Error opening the file.", Toast.LENGTH_SHORT).show(); } } ``` LogCat: ``` 11-19 00:21:54.252: D/fcheck(5885): /storage/sdcard/mylibman.csv 11-19 00:21:54.272: D/File open error(5885): java.io.FileNotFoundException: /storage/sdcard/mylibman.csv: open failed: EACCES (Permission denied) ```

Original source