简体   繁体   中英

How to create a folder in the phone memory (not SD card) in Android?

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?

You can follow this link

Creating Folder in Internal memory

hopefully you are helpful from above link.

Best of luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM