2013-07-13 2 views
0

다운로드 관리자를 사용하여 내 서버에서 MP3 파일을 다운로드하고 있습니다.다운로드중인 파일이 데이터 폴더 내에 저장됩니다.

여기 코드가 있습니다.

public String createFilePath() 
    { 
     String path; 
     String dir = "APP_NAME"; 

     path = Environment.getExternalStorageDirectory().getPath(); 



     File file = new File(Environment.getExternalStorageDirectory(),dir); 
     if(!file.exists()) 
     { 
      file.mkdir(); 
     } 

     path += "/" +dir + "/"; 

     System.out.println("-- saving path : " + path); 
     return path; 
    } 

    public void startDownload() { 
     Uri uri=Uri.parse(URLFixer.Fix(DATA.url)); 




     System.out.println("-- download path : " + createFilePath() + FileNameGetter.getFileName(DATA..url)); 

     DownloadManager.Request request = new Request(uri); 
     request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |DownloadManager.Request.NETWORK_MOBILE); 
     request.setAllowedOverRoaming(false); 
     request.setTitle(DATA..title); 
     request.setDescription(DATA.artist + " - " + DATA.album); 


     request.setDestinationInExternalFilesDir(activity, createFilePath(), FileNameGetter.getFileName(DATA..url)); 
     //  request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); 




     if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) { 
      //     request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN); 
      request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); 
     } 


     lastDownload= mgr.enqueue(request); 
     isDownloading = true; 
     Toasts.pop(activity, "Download Started!!"); 

     //  v.setEnabled(false); 
     //  findViewById(R.id.query).setEnabled(true); 
    } 

문제는 "APP_NAME"폴더 안에 SD 카드에 저장해야한다는 것입니다,하지만 오디오가 다운로드되면, 그 폴더 안에 그것을보고, 어차피 나는 오디오를 재생하고, 그 정보를 확인하는 경우 , thie와 같은 경로를 보여줍니다.

데이터 폴더 내에 저장되어있어 사용자가 파일을 볼 수 없습니다. 사용자가 볼 수 있도록 기본 SD 카드 (예 :/mnt/sdcard/APP_NAME)로 이동하는 방법을 수정하는 방법

답변