In our application (Xamarin C #) we download files from the server. At the end of a successful download, we get the URI for the newly downloaded file and from the URI we get the file path:
Android.Net.Uri uri = downloadManager.GetUriForDownloadedFile(entry.Value); path = u.EncodedPath;
In Android 4.4.2 and on Android 5, the uri and path are as follows:
uri="file:///storage/emulated/0/Download/2.zip" path = u.EncodedPath ="/storage/emulated/0/Download/2.zip"
Then we use the path to process the file. The problem is that in Android 6 (on a real Nexus phone) we get a completely different uri and path :
uri="content://downloads/my_downloads/2802" path="/my_downloads/2802"
This breaks my code, raising a FileNotFound exception. Please note that the downloaded file exists and is located in the Downloads folder. How can I use the URI that I get with Android 6 to get the correct file path so that I can in the file and process it?
Thanks, donescamillo@gmail.com
source share