我正在使用以下代码创建文件夹:
File f = new File(Environment.getExternalStorageDirectory(), folder_main);
if (!f.exists()) {
f.mkdirs();
this.showDialog("Done");
}
else{
this.showDialog("Exist");
}
此代码显示Exist和Done正确,但是当我使用文件浏览器转到SD卡时,我看不到创建的文件夹。为什么以及如何使其发挥作用?
答案 0 :(得分:1)
我的意思是,试试这个(确保f
目前不存在):
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");
}