2014-12-22 5 views
0

디렉토리를 생성하려고하는데 예외를 발생시키지 않고 코드가 실행되지만 디렉토리가 생성되지 않습니다 (Mac의 Android File Transfer 앱에서 확인). 로그에 항목이 없습니다. 여기서 뭐가 잘못 됐어?디렉토리가 생성되지 않았습니다.

File path = getFilesDir(); 

    File filenew = null; 

    try { 
     filenew= new File(path+"/equation"); 
     filenew.mkdirs(); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
+0

getFilesDir을() getPath + "/방정식 " –

+0

가능한 두 (안드로이드에서 디렉토리를 만드는 방법)의 plicate (http://stackoverflow.com/questions/4776426/how-to-create-a-directory-in-android) – duggu

+0

'File filenew = new File (getFilesDir), "equation");) filenew.mkdirs()' –

답변

1

가 이런 식으로 시도 해보십시오 : 권한 여기

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

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

장소에 코드 것입니다.

String externalDirectory= Environment.getExternalStorageDirectory().toString(); 
File folder= new File(externalDirectory + "/NewFolder"); 
folder.mkdir(); 
1

File root = new File(Environment.getExternalStorageDirectory(), "/MYFOLDER"); 
      if(!root.exists()){ 
       root.mkdirs(); 
       } 
+0

작동하지 않습니다. 이상한 것은 내 변수 파일에/storage/emulated/0/equation이 포함되어 있다는 것입니다. filenew = new File (Environment.getExternalStorageDirectory(), "equation"); filenew.mkdirs(); – michaelsmith

+0

장치가 재부팅되었습니다. 이제 디렉토리가 있습니다. 이상한 ... – michaelsmith

+0

그 작동 방법. 내 대답을 Upvote :) –

관련 문제