2012-07-05 79 views
0

我在Android的服務器使用DownloadManager類下載文件保存數據到內存中。我想將此文件存儲在設備的內部存儲器中。我試圖用.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory() +"/Android/data/xxx.xxx.xxx/files/")提到here,但它不工作。如何解決我的問題?安卓:使用下載

+1

「但它不工作」 - 你面臨的問題是什麼?我越來越: – user370305 2012-07-05 09:48:24

+0

如果你這樣做 – 2012-07-05 09:49:52

+0

@ user370305您將獲得權限錯誤沒有這樣的文件或目錄 – 2012-07-05 09:51:34

回答

0

添加

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

到manifest.xml中,打造 「/Android/data/xxx.xxx.xxx/files/」 路徑

+0

我正在使用此權限,但仍然得到:沒有這樣的文件或目錄 – 2012-07-05 09:51:06

+0

只嘗試此路徑.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory()) – Gorets 2012-07-05 09:55:20

+1

我希望我的文件保存在設備的內部存儲器中,而不是在SD卡中。 – 2012-07-05 09:57:01

0

試試這個

File testDirectory = new File(Environment.getExternalStorageDirectory() +"/Android/data/xxx.xxx.xxx/files/"); 

if (!testDirectory.exists()) { 
    testDirectory.mkdirs(); 
     } 
+0

不工作時,setDestinationInExternalPublicDir方法不適用於(文件,字符串) – 2012-07-05 10:31:03

+0

上方運行''setDestinationInExternalPublicDir – 2012-07-05 10:34:01

+0

@M穆赫辛納伊姆執行前,代碼:這就是我試過,不工作 – 2012-07-05 10:35:48