I\'m using DownloadManager to download a file from a webService. The download end successfuly, but when I try to open the new file in the \"download\" folder I\'ve got this erro
Yes you have to specify the MIME type. Adding a few more details to the accepted answer.
public DownloadManager.Request setMimeType (String mimeType);
To get MIME type you can use the following function.
private String getMimeFromFileName(String fileName) {
MimeTypeMap map = MimeTypeMap.getSingleton();
String ext = MimeTypeMap.getFileExtensionFromUrl(fileName);
return map.getMimeTypeFromExtension(ext);
}
and the following is the Xamarin.Android implementation of the same :
private static string GetMimeTypeFromFileName(string fileName)
{
var map = MimeTypeMap.Singleton;
var ext = MimeTypeMap.GetFileExtensionFromUrl(fileName);
return map.GetMimeTypeFromExtension(ext);
}
Okay I found the problem !
I had to specify the "MIME content type" of the file using setMimeType().
public DownloadManager.Request setMimeType (String mimeType);