I want to create a folder in SD card ,and i already add the permission
<user-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in manifest file.below is my code,but mkdirs return false! Can you help me!
File exportDir = new File(
                Environment.getExternalStorageDirectory().toString(), "happydiarybackup");
        if (!exportDir.exists()) {
            boolean a = exportDir.mkdirs();
            Log.d("mkdir ",exportDir.getAbsolutePath() + " make "+ a);
        }
Try this. It might help you.
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/happydiarybackup/";
try
{
    File dir = new File(fullPath);
    if (!dir.exists()) {
      dir.mkdirs();
    }
}
 catch (Exception e) {
   Log.e("App", "Exception" + e.getMessage());
}
1.Check your compileSdkVersion 2.Android: mkdirs()/mkdir() on external storage returns false. Make sure your put the permission tag in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With