I'm calling for your help, I'm stuck for my android project, and I can't find a solution.
Explanation :
I retrieve an .ics (iCalendar) file from a URL on the internet with the Apache Common library using FileUtils.copyURLToFile(url, file). It works very well, my file is created with my data and it is readable.
I save my file in the path : /storage/emulated/0/Android/data/MyApplication/MyFile.ics.
I can see it in the files of the phone (Android Pie) and/or the emulator (Android Oreo) at this address. So it is well created and present.
But when I want to parse my file with the iCal4j library, I get an error with the line containing FileInputStream, telling me that my file or directory does not exist at this address.
EDIT I specify that I check that my file exists with file.exist(). If it exists then it calls the function to parse my file. Where I have a problem with the FileInputStream. So yes, file.exist() tells me that it exists.
File file = new File(Environment.getExternalStorageDirectory() + "/Android/data/MyApplication/MyFile.ics");
FileInputStream fin = new FileInputStream(file.getPath());
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(fin);
I get one mistake.
My errors :
W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Android/data/MyApplication/MyFile.ics (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:200)
at java.io.FileInputStream.<init>(FileInputStream.java:150)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
My manifest.xml :
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
and I also asked the user's permission to access the storage:
requestPermissions(new String[]{WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE}, 1);
I hope I was clear enough to get help, thank you.