2014-12-23 5 views
2

사용자는 자신의 콘텐츠를 다운로드 할 디렉토리를 결정할 수 있습니다. 이제 입력 된 디렉토리를 만들 수 있는지 확인하기 위해 구현이 유효합니다. 어떻게하면됩니까?유효한 경로/디렉토리 확인

Thx.

public class DownloadLocationPickerDialog extends Dialog implements OnClickListener { 

final EditText path = (EditText) findViewById(R.id.pick_location_dialog_path); 

    public void onClick(final View v) { 
    switch (v.getId()) { 
     case R.id.pick_location_dialog_ok: { 
      if (listener != null) { 

       final EditText path = (EditText) findViewById(R.id.pick_location_dialog_path); 
       final String loc = path.getText().toString(); 
       listener.onDownloadLocationChanged(loc); 
      } 
      dismiss(); 
     } 
      break; 
     case R.id.pick_location_dialog_cancel: { 
      dismiss(); 
     } 
      break; 
     case R.id.pick_location_dialog_choose_path: { 

      // 
     } 
      break; 
    } 
}} 

답변

0

디렉토리는 SD 카드에있는 경우 : 그렇지

File d = new File(Environment.getExternalStorageDirectory() + "/dir_name"); 

:

if(d.isDirectory()) { #do something } 

Link

:이 디렉토리의 경우
File d = new File("/dir_name"); 

확인하기
+0

안녕하세요. Steve Olson, Thx이지만 'Dir'은 작동하지 않으며 별도의 수업을 만들어야합니다. 내 코드를 어떻게 구현합니까? 다시 Thx. – Bjorn

+0

내가 thx있어, 내가 너무 피곤해 같아요 :) – Bjorn

+0

안녕하세요 스티브 질문/사용자가/storage/emulated/0/home ///에 대한 디렉토리를 생성하는 피할 수있는 방법이 무엇입니까 그것은 유효한 하나 여야합니다/storage/emulated/0/home/ Thx again – Bjorn

관련 문제