0

We have an issue with downloading any type of file from our server to our phone.
The problem that we have is that we get an access denied error every time we try to save the said file to phone External Memory.

Access to the path "/storage/emulated/0/Download/Test.txt" is denied.


We have given it all the permissions that we found in:
https://developer.android.com/training/data-storage
for both Documents and other files and Media.

Does anyone have any idea why would this be happening? The 'downloading' the file is not the problem, but the saving part is.

1
  • Could you please share some code with us? Commented May 4, 2020 at 8:56

1 Answer 1

1

After Android 6.0 , we need to request the permissions in runtime . In xamarin , you could use the plugin PermissionsPlugin to request runtime permission .

Usage

using Plugin.Permissions; using Plugin.Permissions.Abstractions; 
bool shouldRequest = await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage); if(shouldRequest) { PermissionStatus status = await CrossPermissions.Current.RequestPermissionAsync<StoragePermission>(); if(status==PermissionStatus.Granted) { //do something you want } else { //... } } 

For more details about the plugin you could check the github project site .

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, we ended up using this a moment before you sent it in.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.