0
I have an application in Flutter that generate file and compact in the Android download directory and makes available to the user. In Devices with Android 9, It was no problem, but the on Android 10 devices I have the following error:
Unhandled Exception: FileSystemException: Cannot create file, path =
'/storage/emulated/0/Download/backupPositive2021-03-10 17:23:05.608854.zip' (OS Error: Permission
denied, errno = 13)
I’ve already given the necessary permissions on Androidmanifest and I’m using the "permission_handler" where I check if I have permission. The code is like this:
var enconder = ZipFileEncoder();
var dataNow = new DateTime.now();
var status = await Permission.storage.status;
if (!status.isGranted) {
await Permission.storage.request();
}
downloadsDirectory = await DownloadsPathProvider.downloadsDirectory;
enconder.create(
downloadsDirectory.path + '/backupPositive${dataNow.toString()}.zip');
enconder.addFile(io.File(path));
enconder.close();
It is no use just asking for permission, the user has to give permission. In this example, however silly it may seem, has the user given access? In your code you have no validation as to the new status of the permission after requesting it.
– Julio Henrique Bitencourt
Good evening and thank you for the reply, yes access was released, I myself tested it on an Xiaomi and when debugging the code, in the permission check the same is stated as granted.
– Ronaldo Lopes
Check in the documentation if on android 10 there is no additional permission.
– Matheus Ribeiro
@Matheusribeiro, I found no special permission that needs to be stated, I saw that there were changes to Android 10 e 11.
– Ronaldo Lopes