zoukankan      html  css  js  c++  java
  • android setDestinationInExternalPublicDir 下载到SD卡根目录

    一: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     }
  • 相关阅读:
    区块链入门
    上海美食餐厅
    《OD学hadoop》20160910某旅游网项目实战
    《OD学hadoop》20160904某旅游网项目实战
    《OD学hadoop》20160903某旅游网项目实战
    qt5-自定义类
    qt5-Qt Creator使用
    qt5-QPushButton按钮
    qt5-工程文件的介绍--快捷键
    电路分析-电阻
  • 原文地址:https://www.cnblogs.com/jenson138/p/4456220.html
Copyright © 2011-2022 走看看