Reputation: 24583
I am trying to figure out the best way to determine a file extension given a mime type in android.
This is typically coming in the form of a content uri so I get the mime type as follows:
ContentResolver contentResolver = context.getContentResolver();
String mimeType = contentResolver.getType(uri);
From there I have been using MimeTypeMap:
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String extension = mimeTypeMap.getExtensionFromMimeType(mimeType);
This works great in most cases however there are a few glaring holes, one of them being that there is no entry for "audio/mp4".
Is there a more complete mapping I can use that is built into Android? Or any other ideas?
Upvotes: 3
Views: 3187
Reputation: 1007544
Is there a more complete mapping I can use that is built into Android?
No, sorry.
Or any other ideas?
Bake a MIME type map of your own into your app. See:
...and so on.
Upvotes: 1