Java opening a file created outside the application


Hello. I'm trying to write an android application (6.0 in this case). There was a problem during implementation: You need to open a file that was not created by the application. Moving the file to the right directory (namely, the application directory) is not a problem. The problem is that the application can only open the file that was previously created by this application. When I try to open any other files, I get Permission denied. Moreover, the permissions for reading / writing from the card are set in the manifest (as if this helps), in the phone all the checkboxes on the permissions are set. Is there any way to open such a file for reading?

void writeFile() {
    try {
        // отрываем поток для записи

        BufferedReader br = new BufferedReader(new InputStreamReader(
        String line = "";
        String FileContent = "";
        String NL = System.getProperty("line.separator");
        while ((line = br.readLine()) != null) {
            FileContent = FileContent + line + NL;
        FileContent = FileContent.replaceAll("(H|h)(E|e)(L|l)(L|l)(O|o)",
        BufferedWriter bw = new BufferedWriter(new FileWriter(FILENAME));
        Log.d(LOG_TAG, "Файл записан");
    } catch (FileNotFoundException e) {
    } catch (IOException e) {


I tried to read files, everything worked fine before I tested it on a 6.0 device. Since version 6.0, the following feature is introduced:

if((ContextCompat.checkSelfPermission(Context ctx,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE) ) != 0) {
                        ActivityCompat.requestPermissions(Activity act,
                        new String[]Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
Scroll to Top