2012-07-10 3 views
2

Android에서 DownloadManager 클래스를 사용하여 서버에서 데이터를 다운로드하고 있습니다. 외부 메모리 대신 내부 메모리 (data/data/mypackage/files/...)에 데이터를 저장하려고합니다. 이 작업을 수행하는 방법? 이 같은Android : 내부 메모리에 DownloadManager를 사용하여 다운로드 한 데이터 저장

DownloadManager dm = (DownloadManager) DownloadApplicationActivity.this.getSystemService(Context.DOWNLOAD_SERVICE); 
    DownloadManager.Request req = new DownloadManager.Request(Uri.parse(MY_LINK)); 
    req.setTitle(MY_TITLE) 
        .setDescription("Downloading ....") 
        // download the package to the /sdcard/downlaod path. 
        .setDestinationInExternalPublicDir(
          Environment.DIRECTORY_DOWNLOADS, 
          MY_PATH); 
      long enqueue = dm.enqueue(req); 
+0

[중복?] (http://stackoverflow.com/q/6494627/181714) – Audrius

답변

-1

시도 뭔가 :

// if there is no SD card 
     if (Environment.getExternalStorageState() == null) { 
      directory = new File(Environment.getDataDirectory() 
        + "/RobotiumTestLog/"); 
      photoDirectory = new File(Environment.getDataDirectory() 
        + "/Robotium-Screenshots/"); 

      // if no directory exists, create new directory 
      if (!directory.exists()) { 
       directory.mkdir(); 
      } 

      // if phone DOES have sd card 
     } else if (Environment.getExternalStorageState() != null) { 
      // search for directory on SD card 
      directory = new File(Environment.getExternalStorageDirectory() 
        + "/RobotiumTestLog/"); 
      photoDirectory = new File(
        Environment.getExternalStorageDirectory() 
          + "/Robotium-Screenshots/"); 

      // if no directory exists, create new directory to store test 
      // results 
      if (!directory.exists()) { 
       directory.mkdir(); 
      } 
     } 
+0

그것은 작동하지 않았다! –

+0

당신이 한 일을 우리에게 보여줄 수 있습니까? – BlackHatSamurai

+0

@BlaineOmega :이 코드를 사용하는 방법? setDestinationInExternalPublicDir (디렉토리, "bla.ext") 또는 무엇인가? – RvdK

관련 문제