Answers for "how to create file in folder android studio"

1

create file android java specific folder

try {
        String rootPath = Environment.getExternalStorageDirectory()
                .getAbsolutePath() + "/MyFolder/";
        File root = new File(rootPath);
        if (!root.exists()) {
            root.mkdirs();
        }
        File f = new File(rootPath + "mttext.txt");
        if (f.exists()) {
            f.delete();
        }
        f.createNewFile();

        FileOutputStream out = new FileOutputStream(f);

        out.flush();
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
Posted by: Guest on August-05-2021

Code answers related to "how to create file in folder android studio"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language