2

I tried the following code to implement what I need

File direct = new File(Environment.getRootDirectory() + "/YourFolder");

if (!direct.exists()) {
  if (direct.mkdir()) {
    Toast.makeText(getApplicationContext(), "Yes make directory", Toast.LENGTH_LONG).show();
  }
  else
  {
    Toast.makeText(getApplicationContext(), "No make directory", Toast.LENGTH_LONG).show();
  }
}

I also added the following permission in the AndroidManifest.xml file

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

But it doesn't work. It just displays the toast message "No make directory".

Can anyone suggest where I am going wrong or propose an alternate method to implement the same?

Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
kablu
  • 629
  • 1
  • 7
  • 26
  • 1
    `But not works.` the most useless thing that you can say in software ;) - what does this mean? Your app crashes? The directory is not created? The directory is created in the wrong place? The sun stops shining? Your cat died? – Simon May 21 '14 at 05:38
  • http://stackoverflow.com/a/8124723/903469 – MKJParekh May 21 '14 at 05:38
  • Use `Environment.getExternalDirectory()`, instead. – Phantômaxx May 21 '14 at 06:54

1 Answers1

2

You can follow this link

Creating Folder in Internal memory

hopefully you are helpful from above link.

Best of luck!

Community
  • 1
  • 1
nurealam11
  • 537
  • 4
  • 16