Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Nexus 5创建隐藏文件夹的代码已停止工作_Android_Sd Card_Mkdir - Fatal编程技术网

Android Nexus 5创建隐藏文件夹的代码已停止工作

Android Nexus 5创建隐藏文件夹的代码已停止工作,android,sd-card,mkdir,Android,Sd Card,Mkdir,//这段代码在Nexus5上运行了好几个月,但突然它停止了工作,但是//它在所有其他设备上运行良好,即使是那些具有相同操作系统版本Kitkat的设备。下面是我的//代码。请尽快建议。已检查清单中的所有权限,它们都正常 public static File getPictureStoragePath(int storageLocInt) { // TODO Auto-generated method stub String path = Environment.g

//这段代码在Nexus5上运行了好几个月,但突然它停止了工作,但是//它在所有其他设备上运行良好,即使是那些具有相同操作系统版本Kitkat的设备。下面是我的//代码。请尽快建议。已检查清单中的所有权限,它们都正常

 public static File getPictureStoragePath(int storageLocInt) {
        // TODO Auto-generated method stub
        String path = Environment.getExternalStorageDirectory()
                .getAbsolutePath().toString()
                + "/.DriverMaticsV/"
                + ActiveJourney.JOURNEY_FOLDER_ID
                + "/Picture/";
        Map<String, File> externalLocations = ExternalStorage
                .getAllStorageLocations();
        File sdCard = externalLocations.get(ExternalStorage.SD_CARD);
        File externalSdCard = externalLocations
                .get(ExternalStorage.EXTERNAL_SD_CARD);
        Environment.getExternalStorageState();
        //long count = System.currentTimeMillis();
        if (sdCard == null) {
            path = null;
        } else {
            path = sdCard.getAbsolutePath() + "/.DriverMaticsV/"
                    + ActiveJourney.JOURNEY_FOLDER_ID + "/Picture/";
        }
        if (externalSdCard != null) {
            if (storageLocInt == 0) {
                path = sdCard.getAbsolutePath() + "/.DriverMaticsV/"
                        + ActiveJourney.JOURNEY_FOLDER_ID + "/Picture/";
            } else {
                path = externalSdCard.getAbsolutePath() + "/.DriverMaticsV/"
                        + ActiveJourney.JOURNEY_FOLDER_ID + "/Picture/";
            }
        }
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        return file;
    }
公共静态文件getPictureStoragePath(int-StorageLocaint){
//TODO自动生成的方法存根
String path=Environment.getExternalStorageDirectory()
.getAbsolutePath().toString()
+“/.DriverMaticsV/”
+ActiveTravely.Travely\u文件夹\u ID
+“/图片/”;
映射外部位置=外部存储
.getAllStorageLocations();
文件sdCard=externalLocations.get(ExternalStorage.SD_-CARD);
文件externalSdCard=externalLocations
.get(外部存储。外部SD卡);
getExternalStorageState();
//长计数=System.currentTimeMillis();
如果(SD卡==null){
path=null;
}否则{
path=sdCard.getAbsolutePath()+“/.DriverMaticsV/”
+ActiveTravely.Travely_文件夹_ID+“/Picture/”;
}
如果(外部SD卡!=null){
if(storageLocInt==0){
path=sdCard.getAbsolutePath()+“/.DriverMaticsV/”
+ActiveTravely.Travely_文件夹_ID+“/Picture/”;
}否则{
path=externalSdCard.getAbsolutePath()+“/.DriverMaticsV/”
+ActiveTravely.Travely_文件夹_ID+“/Picture/”;
}
}
文件=新文件(路径);
如果(!file.exists()){
mkdirs()文件;
}
返回文件;
}

您做了哪些调试工作?启动一个Eclipse项目,复制此代码,设置断点,然后逐步查看它在哪里不起作用,这似乎很简单。还有,你说的“它停止工作”是什么意思?函数是否返回null?引发异常?我检查了SD卡中的文件夹,发现它正在创建一个文件,但不是一个名为“.DrivermaticsV”的目录/文件夹(如果我删除“)。它正确创建了所有文件夹。请帮忙。