如何在Android的外部存储目录中的文件夹? [英] how to create a folder in android External Storage Directory?
本文介绍了如何在Android的外部存储目录中的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能创建在Android的外部存储目录中的文件夹。
我已经加入permissing的清单,
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
下面是我的code:
。 字符串路径= Environment.getExternalStorageDirectory()getPath()的toString()+/ Shidhin / ShidhiImages;
的System.out.println(路径:+路径);
文件FPath =新的文件(路径);
如果(!FPath.exists()){
如果(!FPath.mkdir()){
的System.out.println(***问题创造图片的文件夹+路径);
}
}
解决方案
做这样的:
字符串folder_main =NewFolder;
文件F =新的文件(Environment.getExternalStorageDirectory()
folder_main);
如果(!f.exists()){
f.mkdirs();
}
如果你想创建另一个文件夹成:
文件F1 =新的文件(Environment.getExternalStorageDirectory()+/
+ folder_main,产品1);
如果(!f1.exists()){
f1.mkdirs();
}
I cannot create a folder in android External Storage Directory.
I have added permissing on manifest,
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Here is my code:
String Path = Environment.getExternalStorageDirectory().getPath().toString()+ "/Shidhin/ShidhiImages";
System.out.println("Path : " +Path );
File FPath = new File(Path);
if (!FPath.exists()) {
if (!FPath.mkdir()) {
System.out.println("***Problem creating Image folder " +Path );
}
}
解决方案
Do it like this :
String folder_main = "NewFolder";
File f = new File(Environment.getExternalStorageDirectory(),
folder_main);
if (!f.exists()) {
f.mkdirs();
}
If you wanna create another folder into that :
File f1 = new File(Environment.getExternalStorageDirectory() + "/"
+ folder_main, "product1");
if (!f1.exists()) {
f1.mkdirs();
}
这篇关于如何在Android的外部存储目录中的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文