Pages

Tuesday 22 December 2015

Android Mime Type File manager

In Following link have working example of Mime Type File manager.

It will display photo,video or audio from external attached device. in case if it's not working than remove sd-card and re-insert it. then try. or try with phone restart.

Demo :
https://sites.google.com/site/fancifulandroid/android-projects/USB-connection%28FileManager%29.zip?attredirects=0&d=1

Android get mime type of file or url

Use following function to get MIME Type of file. pass file path or any url

public static String getMimeType(String url) {
  try {
   String type = null;
   String extension = url.substring(url.lastIndexOf(".") + 1, url.length());
   Log.i("extension", "ext : " + extension);
   if (extension != null) {
    type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
   }
   return type;
  } catch (Exception e) {
   e.printStackTrace();
  }
  return null;
}