0
I have the following code:
String f = getStringFromFile(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/PagamentoLio.json");
String getStringFromFile (String filePath) {
File fl = new File(filePath);
FileInputStream fin = null;
String error = "";
try {
fin = new FileInputStream(fl);
String ret = convertStreamToString(fin);
//Make sure you close all streams.
fin.close();
return ret;
} catch (FileNotFoundException e) {
error = e.getMessage();
e.printStackTrace();
} catch (IOException e) {
error = e.getMessage();
} catch (Exception e) {
error = e.getMessage();
}
showMessageError(error);
return "";
}
But when he gets on the line fin = new FileInputStream(fl);
is pitching FileNotFoundException
, the problem is that the file exists and is on the right track. I tried with other files and the same thing happens. What might be causing this?
Did you declare/request permission to read the external storage? Because the comment itself indicates that permission has been denied
– Ivan Silva
I think that’s exactly what’s missing... I’ll try to resolve. Thank you!
– Artur Brasil