title: How to open .crt file in Android ?
body: <p>Few devices in android unable to read .crt (Certificate File) whereas few can. How to deal with this device related issue ? Is there any other Intent to open file other than ACTION_VIEW which can be an alternative to open file. </p>
  
  <pre><code>File vpnCerti = new File("/sdcard/VPNCertificate/Install.crt");
                  Uri path = Uri.fromFile(vpnCerti); //Mime Type Info : http://webdesign.about.com/od/multimedia/a/mime-types-by-content-type.htm
                  MimeTypeMap type_map = MimeTypeMap.getSingleton();
                  //Get the extension from the path
                  String extension = MimeTypeMap.getFileExtensionFromUrl(path.toString());
                  extension = extension.toLowerCase();
                  if (extension.contains(".")) {
                      extension = extension.substring(extension.lastIndexOf("."));
                  }
                  String mime_type = type_map.getMimeTypeFromExtension(extension);
                  Log.d("DownloadManager", "MIME Type : " + mime_type);
                  Intent i = new Intent();
                  i.setAction(android.content.Intent.ACTION_VIEW);
                  i.setDataAndType(Uri.fromFile(vpnCerti), mime_type);
                  i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
                  try
                  {
                      Log.d("DownloadManager", "Trying to open file");
                      startActivity(i);
                      Log.d("DownloadManager", "Opened file");
                  }
                  catch(ActivityNotFoundException e)
                  {
                      Log.d("DownloadManager", "Couldn't open file");
                      Toast.makeText(SettingsActivity.this, "Couldn't find specific activity to open it", Toast.LENGTH_LONG).show(); 
                  }
  </code></pre>