Create directory failed in file system

Put your problem here if it does not fit any of the other categories.

Create directory failed in file system

Postby cabernet1976 » Thu Jan 17, 2008 5:29 pm

Create directory successfully in SD card:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.            File sddir = new File("/sdcard/mydir1");
  2.  
  3.                 if (!sddir.mkdirs()) {
  4.  
  5.                         Log.e(TAG, "Create dir in sdcard failed");
  6.  
  7.                         return;
  8.  
  9.                 }
Parsed in 0.116 seconds, using GeSHi 1.0.8.4


But create dir failed in file system:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 try {
  2.  
  3.                         File dir = getFileStreamPath("mydir2");
  4.  
  5.                         if (!dir.mkdirs()) {
  6.  
  7.                                 Log.e(TAG, "Create dir in local failed"); //<--print this error
  8.  
  9.                                 return;
  10.  
  11.                         }
  12.  
  13.                 } catch (FileNotFoundException e1) {
  14.  
  15.                         Log.e(TAG, "error 1: "+e1.toString());
  16.  
  17.                 }
Parsed in 0.116 seconds, using GeSHi 1.0.8.4


Could you tell me what I have missed? :roll:
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Postby plusminus » Mon Jan 21, 2008 9:00 am

Hello cabernet1976,

In the future SDKs there will be a new set of APIs explicitly for creating directories.
This is said to work (but I cannot check it where I am currently):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getFileStreamPath( "my/directory/name" ).mkdirs()
Parsed in 0.081 seconds, using GeSHi 1.0.8.4

Perhaps yours is not working, because it already exists (already created a run before :?: ) :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2696
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby cabernet1976 » Tue Jan 22, 2008 2:18 am

Thanks plusminus.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby thao » Tue Oct 28, 2008 4:30 pm

Hello,

I've got the opposite issue as cabernet1976. I succeed to create some folder in the /data/data/myApp folder but nothing on the SDcard with the same code.

Is there any permission to grant or something like that ?
Please Advise.
Thank
thao
Freshman
Freshman
 
Posts: 4
Joined: Tue Oct 28, 2008 3:35 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: pskink and 1 guest