create file android java specific folder

Solutions on MaxInterview for create file android java specific folder by the best coders in the world

showing results for - "create file android java specific folder"
Neele
16 Apr 2016
1try {
2        String rootPath = Environment.getExternalStorageDirectory()
3                .getAbsolutePath() + "/MyFolder/";
4        File root = new File(rootPath);
5        if (!root.exists()) {
6            root.mkdirs();
7        }
8        File f = new File(rootPath + "mttext.txt");
9        if (f.exists()) {
10            f.delete();
11        }
12        f.createNewFile();
13
14        FileOutputStream out = new FileOutputStream(f);
15
16        out.flush();
17        out.close();
18    } catch (Exception e) {
19        e.printStackTrace();
20    }
21