One: Setdestinationinexternalpublicdir ("Trinea", "meilishuo.apk"); Represents the Trinea folder set to the SD card with the file name meilishuo.apk.
Set the download path interface to Setdestinationuri,setdestinationinexternalfilesdir,setdestinationtosystemcache. Where Setdestinationtosystemcache is only available for system apps.
Two: Downloadmanager download to the built-in directory with this setdestinationinexternalfilesdir (Context,null,filename)
Create folder under SD card root directory
1 /**2 * Get the program to specify sdcard file download directory3 * Built-in SDcard4 * App Common directory5 */6 Public StaticString Getcommonpath () {7 //have SD card8 if(Environment.MEDIA_MOUNTED.equals (Environment9 . Getexternalstoragestate ())) {Ten //Create a Folder object that is assigned to the directory of the external memory OneFile Sdcarddir =environment.getexternalstoragedirectory (); A //get a path with the contents of the SDcard folder path and name -String path = Sdcarddir.getpath () + "/" + "test"; -File path1 =NewFile (path); the if(!path1.exists ()) - //If it does not exist, create a directory that can be created when the app starts - path1.mkdirs (); - + returnpath; -}Else{ + //No SD card A return""; at } - -}
Android setdestinationinexternalpublicdir download to sd card root directory