-1

I am creating folder with following code:

File f = new File(Environment.getExternalStorageDirectory(), folder_main);
if (!f.exists()) {
    f.mkdirs();
    this.showDialog("Done");
}
else{
    this.showDialog("Exist");
}

This code show Exist and Done correctly, but when I go to sd card with file explorer, I cannot see created folders. Why and how to make it work?

Tunaki
  • 125,519
  • 44
  • 317
  • 399
Majid Abbasi
  • 1,521
  • 2
  • 11
  • 22

1 Answers1

1

I mean, try this(make sure f currently doesn't exist):

File f = new File(Environment.getExternalStorageDirectory(), folder_main);
if (!f.exists() && f.mkdirs()) {
    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(f)));
    this.showDialog("Done");
}else{
    this.showDialog("Exist");
}
Lym Zoy
  • 931
  • 10
  • 15