Read file in android - file permission denied

后端 未结 3 741

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

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 09:14

    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 statuses = await [
                  Permission.storage,
                ].request();
                print(statuses[Permission.storage]); // it should print PermissionStatus.granted
              }
    

提交回复
热议问题