title: How to get rid of: "FileSystemException: Cannot open file, path = '...' (OS Error: Permission denied, errno = 13)"?
body: <p>I'm trying to display an image from my phone in my Flutter app and getting following error:</p>
  
  <pre><code>Another exception was thrown: FileSystemException: Cannot open file, path = '/storage/emulated/0/Android/data/com.android.providers.media/albumthumbs/1570277797774' (OS Error: Permission denied, errno = 13)
  </code></pre>
  
  <p>I don't understand the <code>Permission denied</code> part, because I added... </p>
  
  <pre><code>  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
    &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>...to my <code>android/app/src/mainAndroidManifest.xml</code> file, and when running the app it shows that it really does have the permissions to read files:<br>
  <a href="https://i.stack.imgur.com/9m82tl.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/9m82tl.jpg" alt="Permissions"></a><br>
  Also the file I'm trying to open exists and seems fine - I can open it with other apps as well:
  <a href="https://i.stack.imgur.com/f8eUj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/f8eUj.jpg" alt="File to open"></a>
  Here's my Code:</p>
  
  <pre><code>import 'dart:io';
  
  import 'package:flutter/material.dart';
  
  void main() =&gt; runApp(FileOps());
  
  class FileOps extends StatefulWidget {
    _FileOpsState createState() =&gt; _FileOpsState();
  }
  
  class _FileOpsState extends State&lt;FileOps&gt; {
    File localFile;
    String widgetTitle = 'Show Image';
  
    @override
    void initState() {
      super.initState();
      localfile.then((File _localFile) {
        setState(() {
          localFile = _localFile;
        });
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: widgetTitle,
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(
            title: Text(widgetTitle),
          ),
          body: Column(
            children: &lt;Widget&gt;[
              Image.file(localFile),
            ],
          ),
        ),
      );
    }
  
    Future&lt;File&gt; get localfile async {
      String imgPath =
          '/storage/emulated/0/Android/data/com.android.providers.media/albumthumbs/1570277797774';
      return File(imgPath);
    }
  }
  </code></pre>
  
  <p>My pubspec.yaml:</p>
  
  <pre><code>name: template_app
  description: A template Flutter app for testing and minimal examples
  
  version: 1.0.0+1
  
  environment:
    sdk: "&gt;=2.1.0 &lt;3.0.0"
  
  dependencies:
    flutter:
      sdk: flutter
    cupertino_icons:
  
  dev_dependencies:
    flutter_test:
      sdk: flutter
  
  flutter:
    uses-material-design: true
  </code></pre>
  
  <blockquote>
    <p>Answers to questions in comments:  </p>
    
    <ul>
    <li>"com.android.providers.media" is not the name of my app, idk what it is - but the image I want to open is there</li>
    <li>My Android Version is 8.0.0, my phone is also running EMUI 8.0.0 (idk what it is exactly, some Huawei stuff)</li>
    <li>I can open the file with the standard app that came with the phone called "Gallery"</li>
    </ul>
  </blockquote>