You will not be able to do this from the filesDir. I had run into the same issue.
You can do the following:
private void playFile(String fileName)
{
try
{
File documentFile = new File(fileName);
String externalStroageString = appContext.getExternalCacheDir()+"/Download/";
File externalStroage = new File(externalStroageString);
File documentFileExternal = new File(externalStroage, documentFile.getName());
if(documentFileExternal.exists())
documentFileExternal.delete();
try
{
FileUtils.copyFile(documentFile, documentFileExternal);
documentFileExternal.setReadable(true, false);
}
catch (IOException e)
{
}
MimeTypeMap map = MimeTypeMap.getSingleton();
int index = documentFileExternal.getName().lastIndexOf(".");
String ext = documentFileExternal.getName().substring(index+1);
String type = map.getMimeTypeFromExtension(ext);
Uri uri = Uri.parse("file://"+documentFileExternal.getAbsolutePath());
if (type == null)
type = "*/*";
try
{
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if(ext.equalsIgnoreCase("htm") || ext.equalsIgnoreCase("html"))
{
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
intent.addCategory(Intent.CATEGORY_BROWSABLE);
}
intent.setDataAndType(uri, type);
appContext.startActivity(intent);
}
catch(Exception ex)
{
ErrorManager.appContext = appContext;
ErrorManager.errorCode = "UnsupportedFileType";
ErrorManager.displayErrorDialog();
}
}
catch(Exception ex)
{}
}
catch(Exception ex)
{
}
}