I am trying to export some data on my app. Even though I set required permission on manifest and deleted build multiple times, it gives the same error. How can I fix it? FileNotFoundException: /storage/emulated/0/VocAppFile/output.txt (No such file or directory) The thing is there is no such folder like above in my phone. But /storage/emulated/0/ is the default directory.
My code is this:
String state = Environment.getExternalStorageState();
    if(Environment.MEDIA_MOUNTED.equals(state)){
        File Root = Environment.getExternalStorageDirectory();
        Log.d("Export to", Root.getAbsolutePath());
        File Dir = new File(Root.getAbsolutePath()+"/AppFile");
        if(!Dir.exists()){
            Dir.mkdir();
        }
        File file = new File(Dir,"output.txt");
        try {
            FileOutputStream fos = new FileOutputStream(file);
            for(String[] d : data){
//data comes ready
                fos.write(d[0].getBytes());
                fos.write(d[1].getBytes());
            }
            fos.close();
            Toast.makeText(getApplicationContext(), "Data exported", 
Toast.LENGTH_SHORT).show();
        }catch (FileNotFoundException e){
            Log.wtf("My activity", "Error in exporting words");
            e.printStackTrace();
        }catch (IOException e){
            Log.wtf("My activity", "Error in exporting words");
            e.printStackTrace();
        }
 
    