gpt4 book ai didi

android - 在 Sdcard 中创建文件夹失败(三星 Galaxy)

转载 作者:行者123 更新时间:2023-11-29 01:13:50 25 4
gpt4 key购买 nike

无法在 samsung Galaxy 中创建文件夹。我尝试通过调用此方法来创建文件夹: 稍后获取存储路径我正在尝试将文件夹名称添加到路径并尝试创建

  Its even showing the path...but no such file was created.

public static String createFolder(String folderName) {
String extFolName = Environment.getExternalStorageDirectory().toString();

f = new File(extFolName + "/" + folderName + "/");
if (f.exists()) {
path = f.getAbsolutePath();
return path;
} else {
if (f.mkdir()) {
path = f.getAbsolutePath();
return path;
}
else
{
//always going to else don't know y //
}
return path;
}

当我尝试检查在 sd 卡中创建的文件夹时,没有文件创建...

最佳答案

public static String createFolder(String folderName) {
String extFolName = Environment.getExternalStorageDirectory().toString();

f = new File(extFolName + "/" + folderName + "/");
if (f.exists()) {
path = f.getAbsolutePath();
return path;
} else {
if (f.mkdirs()) {
path = f.getAbsolutePath();
return path;
}
else
{
//now it will not go to the else part //
}
return path;
}

关于android - 在 Sdcard 中创建文件夹失败(三星 Galaxy),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41162822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com