Get the SD card under android/data/file

Source: Internet
Author: User


Most applications typically choose the location of the cache as the/sdcard/android/data/<application package>/cachepath.
There are two benefits to choose from in this location:
First, this is stored on the SD card, so even if more data is cached it will not have any effect on the phone's built-in storage space as long as the SD card space is sufficient.
Second, the path is identified by the Android system as the application's cache path, and when the program is uninstalled, the data will be erased together, so there will be no more residual data on the phone after the removal process.

//Path Example:/SD card/android/data/program's package name/cache/uniquename  Private StaticFile Getdiskcachedir (context context, string uniqueName) {string CachePath; if(Environment.MEDIA_MOUNTED.equals (Environment. Getexternalstoragestate ())|| !environment.isexternalstorageremovable ()) {CachePath=Context.getexternalcachedir (). GetPath (); } Else{CachePath=Context.getcachedir (). GetPath (); }        return NewFile (CachePath + file.separator +uniqueName); }

Get the SD card under android/data/file

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.