Android setdestinationinexternalpublicdir download to sd card root directory

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.