Through JSON I get some PDFs that I found on base 64 and I keep them in the following way:
OutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory().toString() + "/documentosConsumerTemporal/pdfConsumer_" + oNombreDocumentoMatriz + ".pdf");
out.write(Base64.decode(oDatosDocumentoMatriz, Base64.DEFAULT));
out.flush();
out.close();
And it saves it in the following way:
/storage/sdcard0/documentosTemporal/pdf_SPV.pdf
Then, from another activity I want to launch those PDF's in the following way:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory().toString() + "/documentosConsumerTemporal/pdfConsumer_SPV.pdf"), "application/pdf");
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(ActivityDatosNumeroOperacion.this, Environment.getExternalStorageDirectory().toString() + "/documentosTemporal/pdf_SPV.pdf", Toast.LENGTH_LONG).show();
}
but I get the following error message:
La ruta de acceso al documento no es valida
I have tried saving in the path of the same application with the following code:
OutputStream out = new FileOutputStream(getFilesDir() + "/pdf_" + oNombreDocumentoMatriz + ".pdf");
But he gives me the same message, which he does not find.
I have tried to open the PDF directly and if it opens, but by code no. What can it be? Permissions are OK, do I have to put them in an already established folder?
Thanks