[英]Folder don't see in DDMS whereas folder was created Android
I don't understand why i can't see the folder that i had created in the DDMS of Eclipse. 我不明白为什么我看不到我在DDMS中创建的文件夹。 At the beginning of my activity, i call this method : 在活动开始时,我将此方法称为:
public void createFolderSignature(){
File signaturePointFolder = new File(Environment.getExternalStorageDirectory()+ File.separator + "tour_"+this.point.getId_tour() + File.separator + "point_"+this.point.getId());
Log.i("PATH : " , signaturePointFolder.getPath());
if (!signaturePointFolder.exists()){
Log.i("signaturePointFolder","CREATED");
signaturePointFolder.mkdir();
}else{
Log.i("signaturePointFolder","ALREADY CREATED");
}
}
The tour and point are object. 游览和重点是对象。 So i create a special folder in terms of id of point and tour. 因此,我根据点和游览的ID创建了一个特殊的文件夹。 Like you see, i pet log to see if the folder are create well. 就像您看到的一样,我记录日志以查看文件夹是否创建良好。 So this is my logcat : 这就是我的日志:
06-12 09:31:51.268: I/PATH :(24819): /mnt/sdcard/tour_1/point_1
06-12 09:31:51.268: I/signaturePointFolder(24819): CREATED
06-12 09:31:51.412: D/dalvikvm(24819): GC_CONCURRENT freed 1101K, 10% free 12980K/14343K, paused 18ms+12ms, total 67ms
06-12 09:31:51.716: D/dalvikvm(24819): GC_CONCURRENT freed 1706K, 13% free 13337K/15175K, paused 11ms+15ms, total 66ms
So if see my log "CREATED", i gather that normally, the folder is create well, but no, i see nothing in the File Explorer in Eclipse of my AVD. 因此,如果看到我的日志“ CREATED”,我通常会收集到该文件夹创建得很好,但是没有,我在我的AVD的Eclipse的文件资源管理器中看不到任何东西。 And each time that i arrive to the activity, i have the same log. 而且每次我参加活动时,我都有相同的日志。 Why? 为什么? There are something wrong in my code? 我的代码有问题吗? I hope that you will can help me =) 希望您能帮助我=)
EDIT 1 : i forget to say that i pet the permission WRITE_EXTERNAL_STORAGE and READ_ too in the manifest. 编辑1:我忘了说我也是在清单中宠爱权限WRITE_EXTERNAL_STORAGE和READ_。
Change signaturePointFolder.mkdir()
to signaturePointFolder.mkdirs()
It's required since your creating a herarchy of folders. 将signaturePointFolder.mkdir()
更改为signaturePointFolder.mkdirs()
,因为您创建了文件夹层次结构,所以这是必需的。 mkdir()
works only when there is a single parent. mkdir()
仅在有单亲时起作用。 Hence you need mkdirs() to create the remaining folders as well. 因此,您还需要mkdirs()来创建其余文件夹。
Also make sure that you are providing the write permission in your manifest 还要确保您在清单中提供了写权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
You always get Log.i("signaturePointFolder","CREATED");
您总是会得到Log.i("signaturePointFolder","CREATED");
because the file path always not exists. 因为文件路径始终不存在。
So,Try this 所以,试试这个
public void createFolderSignature(){
File signaturePointFolder = new File(Environment.getExternalStorageDirectory()+ File.separator + "tour_"+this.point.getId_tour() + File.separator + "point_"+this.point.getId());
Log.i("PATH : " , signaturePointFolder.getPath());
if (!signaturePointFolder.exists()){
Log.i("signaturePointFolder","CREATED");
signaturePointFolder.mkdirs();
}else{
Log.i("signaturePointFolder","ALREADY CREATED");
}
}
And don't forgot to add permission in manifest.xml
file 并且不要忘记在manifest.xml
文件中添加权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.