When targeting version 33+ the options to save a json file (in this case to export data between installations) seems to be non existent.
Was anyone able to get this done?
The only references I found where for pdfs or images, but the system scans the file type and does not allow jsons.
I just want the user to be able to export and import their settings.
I am searching for a solution for over 40 hours with no luck, send help.
PathAccessException (PathAccessException: Cannot open file, path = ‘/storage/emulated/0/Download/data.json’ (OS Error: Permission denied, errno = 13))
or
PathAccessException (PathAccessException: Cannot open file, path = ‘/storage/emulated/0/Downloads/data.json’ (OS Error: Permission denied, errno = 2))
The WRITE_EXTERNAL_STORAGE permission is ignored in this version.
Example implementation:
static Future<String> download(String data, String fileName) async {
try {
if (data.isNotEmpty) {
// Get the downloads directory
Directory downloadsDirectory =
Directory('/storage/emulated/0/Downloads/');
final File file = File('${downloadsDirectory.path}$fileName');
if (file.existsSync()) {
return 'File already downloaded';
}
// Write the PDF content to the file
await file.writeAsString(data);
return 'File downloaded';
} else {
return 'Unknown error';
}
} catch (e) {
return 'Unknown error';
}
}
I am only able to not get the permission denied if I store it locally, but then the user can not access the export, which makes it pointless.