0

Can i create a folder into the root of internal storage (ex. on my gs4 /storage/emulated/0/MY_FOLDER). in this pah are present many folder of other app, like viber,audijo whatsapp so i think that it's possible.

Thank you

the code

File folder = new File( Environment.getDataDirectory().getAbsolutePath() + "/storage/emulated/0/MyFolder");
    folder.mkdir();
Anto
  • 907
  • 5
  • 14
  • 26

3 Answers3

2

Yes. It is possible to create a folder in Internal Storage directory as below:

 Environment.getDataDirectory().getAbsolutePath() + "/storage/emulated/0/MyFolder"
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
2

You can create Folder this way.

    public  String  path = Environment.getDataDirectory().getAbsolutePath().toString()+ "/YourDirectoryName";
    File mFolder = new File(path);
                if (!mFolder.exists()) {
                    mFolder.mkdir();
                }
Harshid
  • 5,701
  • 4
  • 37
  • 50
0

Try the following in your activity:

String filename = "filename";
String fileContents = "Text in file.";

FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
fos.write(fileContents.getBytes());
fos.close();
MaxAlexander
  • 460
  • 3
  • 10