I’m writing a basic file browser that changes the icon used for files displayed depending on the MIME type of the file, but I’m having trouble finding the MIME type of some files, and I’m not sure why, the code I’m using to find the MIME Type is thus:
private String getFileMimeType(File file)
{
Uri fileUri = Uri.fromFile(file);
String ext = MimeTypeMap.getFileExtensionFromUrl(fileUri.toString());
return mtm.getMimeTypeFromExtension(ext);
}
It works for some file, but not for some with more complicated characters in them, which I don’t really understand, example below:

The files with tildas are all functional mp3s but all return null for their MIME types, which isn’t good for functioning mp3s, so I’m curious if there’s any simple workaround for files with special chars in their name.
Its because of the “~” character in your filenames.
Look at the implementation of getFileExtensionFromUrl
}
a possible solution would be to write your own implemenation of this method with wider matching rule.
Hope this helps