android setDestinationInExternalPublicDir 下載到SD卡根目錄

來源:互聯網
上載者:User

標籤:

一:setDestinationInExternalPublicDir(“Trinea”, “MeiLiShuo.apk”);表示設定為sd卡的Trinea檔案夾,檔案名稱為MeiLiShuo.apk。
設定下載路徑介面為setDestinationUri,setDestinationInExternalFilesDir,setDestinationToSystemCache。其中setDestinationToSystemCache僅限系統app使用。

二:DownloadManager下載到內建目錄用這個setDestinationInExternalFilesDir(Context,null,filename)

 

 

SD卡根目錄下建立檔案夾

 1     /** 2      * 取得程式指定SDCard檔案下載目錄 3      * 內建sdCard 4      * APP公用目錄 5      */ 6     public static String getCommonPath() { 7         //有sd卡 8         if (Environment.MEDIA_MOUNTED.equals(Environment 9                 .getExternalStorageState())) {10             // 建立一個檔案夾對象,賦值為外部儲存空間的目錄11             File sdcardDir = Environment.getExternalStorageDirectory();12             // 得到一個路徑,內容是sdcard的檔案夾路徑和名字13             String path = sdcardDir.getPath() + "/" + "test";14             File path1 = new File(path);15             if (!path1.exists())16                 // 若不存在,建立目錄,可以在應用啟動的時候建立17                 path1.mkdirs();18             19             return path;20         } else{21             //無SD卡22             return "";23         }24 25     }

 

android setDestinationInExternalPublicDir 下載到SD卡根目錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.