KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have a full path of file like:(/sdcard/tlogo.png). I want to know its mime type. I created a function for it public static String getMimeType(File file, Context context) { Uri uri = Uri.fromFile(file); ContentResolver cR = context.getContentResolver(); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getExtensionFromMimeType(cR.getType(uri)); return type; } but when i call it, it returns null. File file = new File(filePath); String fileType=CommonFunctions.getMimeType(file, context);
Tags (comma-separated)
Save Edits
Cancel