Created
June 4, 2014 10:19
-
-
Save phajduk/2e28254c6e1ecad37785 to your computer and use it in GitHub Desktop.
Getting mime type from file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uri path = Uri.fromFile(file); | |
MimeTypeMap typeMap = MimeTypeMap.getSingleton(); | |
String extension = MimeTypeMap.getFileExtensionFromUrl(path.toString()).toLowerCase(); | |
if (extension.contains(".")) { | |
extension = extension.substring(extension.lastIndexOf(".")); | |
} | |
String mimeType= typeMap.getMimeTypeFromExtension(extension); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment