title: Android: Open a custom file
body: <p>I get a Runtime Error if I want to open a file which cannot handle the Android, like .pm3 (instead of .mp3).</p>
  
  <p>Runtime Error:</p>
  
  <pre><code>E/AndroidRuntime(24095): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/download/ttt.pm3 }
  </code></pre>
  
  <p>Here is my code: </p>
  
  <pre><code>public void executeFile(FileItem fileItem) {
      Intent intent = new Intent();
      intent.setAction(android.content.Intent.ACTION_VIEW);
      File file = new File(fileItem.getFilePath());
  
      MimeTypeMap mime = MimeTypeMap.getSingleton();
      String ext = fileItem.getFileExtension();
      String type = mime.getMimeTypeFromExtension(ext);
  
      intent.setDataAndType(Uri.fromFile(file), type);
  
      this.fileManagerActivity.startActivity(intent);
  }
  </code></pre>
  
  <p>I think that I should put an if before the this.fileManagerActivity.startActivity(intent); line.
  But I don't know how could I check that.</p>
  
  <p>So my question is that, how could I avoid this runtime error?</p>
  
  <p>Thank you for the answers:)</p>