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 de
Make sure you have added the permission to read external storage in your manifest file.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I was experiencing the same problem and it can be easily removed by following either of these steps: 1. Install your app by using -g if installing on Android N and O versions. 2. Grant permission manually Settings->apps->"app_name"->Permissions->Enable Switch
For Both steps 1 and 2, define uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" and uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" in AndroidManifest.xml
Like this :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="...">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- all permissions here -->
<application
...
Storage permission needs to be given by the user before accessing the functionality
Add Dependency:
dependencies:
permission_handler: ^5.0.1
Code Snippet:
var status = await Permission.storage.status;
if (status.isUndetermined) {
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.storage,
].request();
print(statuses[Permission.storage]); // it should print PermissionStatus.granted
}