[Android ]Intent.ACTION_VIEW - Not found
<p>I am having an issue, I have never had problem opening files via <code>ACTION_VIEW</code> the next way:</p>

<pre><code>File file = new File(getActivity().getFilesDir(), TEMP_FILE_NAME);
String dataType = "image/*";

if (file.exists()) {

    Intent fileIntent = new Intent(Intent.ACTION_VIEW);
    fileIntent.setDataAndType(Uri.fromFile(file), dataType);
    fileIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    Intent intent = Intent.createChooser(fileIntent, "Open file");
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        Log.e(TAG, "There is a problem when opening the file");
    }
} else {
    Toast.makeText(getContext(), "Invalido", Toast.LENGTH_LONG).show();
}
</code></pre>

<p>The problem I am having right now is that even though the file exists when I choose the app to open the file it immediately closes and tells me <code>Not found</code>. I have put the image I am loading in an image view and there is no problem, so the file is valid but for some reason it has conflicts when I am opening it via intent. </p>

<p>I am aware that it may have something to do with the way I am creating the file, I am retrieving it from Google drive so I am writing the file using the Apache Commons library the next way:</p>

<pre><code>DriveContents contents = result.getDriveContents();
InputStream inputStream = contents.getInputStream();

File file = new File(getActivity().getFilesDir(), TEMP_FILE_NAME);
try {
    OutputStream outputStream = new FileOutputStream(file);
    IOUtils.copy(inputStream, outputStream);
    IOUtils.closeQuietly(inputStream);
    IOUtils.closeQuietly(outputStream);
} catch (IOException e) {
    e.printStackTrace();
}
</code></pre>

<p>What is it I am doing wrong? I am not totally sure if the problem has to do with the copy method executing asynchronously or something like that.</p>

<p>Thanks in advance.</p>