0

I want to reliably create a file in the Downloads folder of the OS, something that works for all the supported systems.

I'm using Avalonia 11 preview5, in a cross-platform application and I'm running this in Android.

  var downloadFolder = await storageProvider.TryGetWellKnownFolder(WellKnownFolder.Downloads);
  var newFileUri = new Uri(downloadFolder.Path, "Myfile.txt");
  var newFile = await storageProvider.TryGetFileFromPath(newFileUri);

But it throws:

java.lang.SecurityException: Application doesn't have ReadExternalStorage permission. Make sure android manifest has this permission defined and user allowed it.

My AndroidManifest.xml is as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:requestLegacyExternalStorage="true">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> 
    <application android:label="AvaloniaStorateTester" android:icon="@drawable/Icon" />
</manifest>

What am I missing?

SuperJMN
  • 13,110
  • 16
  • 86
  • 185
  • Read here: https://stackoverflow.com/questions/51374551/read-and-write-external-storage-permission-isnt-working#51374708 It seems like the solution is to request permissions. – SupaMaggie70 b Mar 06 '23 at 17:56

0 Answers0