Thomas Trabelsi
Thomas Trabelsi

Reputation: 330

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. 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. 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. 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.

Upvotes: 0

Views: 87

Answers (2)

Giru Bhai
Giru Bhai

Reputation: 14408

You always get 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

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Upvotes: 1

CodeWarrior
CodeWarrior

Reputation: 5176

Change signaturePointFolder.mkdir() to signaturePointFolder.mkdirs() It's required since your creating a herarchy of folders. mkdir() works only when there is a single parent. Hence you need mkdirs() to create the remaining folders as well.

Also make sure that you are providing the write permission in your manifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Upvotes: 1

Related Questions