2014-07-10 5 views
0

내가 사용경로, 호환되지 않는 유형

Path mypath = Environment.getExternalStorageDirectory().getPath() + "/myfile/asong.mp3"; 

을하지만 그건 호환되지 않는 유형을 제공, 문자열 및 필요한 경로를 발견했다. 이 특정 경로의 sdcard 경로를 어떻게 설정할 수 있습니까?

이것은 내가 사용하고 무엇을 : : 감사합니다 많은

답변

1

이 예를 참조

활동 .. createDirIfNotExists ("/ 데이터/XXXX/XXXX/XXX");

public static boolean createDirIfNotExists(String path) { 
    boolean ret = true; 
    File file = new File(Environment.getExternalStorageDirectory().toString()+path); 
    Debug.out(path); 
    if (!file.exists()) { 
     if (!file.mkdirs()) { 
      Debug.out("Problem creating Image folder"); 
      ret = false; 
     } 
    } 
    if (FolderLocation == null) 
     FolderLocation = new File(file.toString()); 
    return ret; 
} 

.... .... 예를 들어 나는 파일에 소리를 녹음 할 :

  File outputFile = new File(FolderLocation, filename+".3gp"); 
      MediaPlayer mp = new MediaPlayer(); 
      try { 
       mp.setDataSource(outputFile.toString()); 
       mp.prepare(); 
       mp.start(); 
      } catch (Exception e) { 
       // e.printStackTrace(); 
       Debug.out("button_play.setOnClickListener ERROR"); 
      } 
1

Path class 파일의 일부 경로가 아닙니다. 그것은 캔버스에있는 드로잉의 경로를 나타냅니다. 파일 경로를 저장하려면 String, Uri 또는 File 객체에 저장할 수 있습니다.