File save directory for Android app

Source: Internet
Author: User

Android app File save directory can be the app's built-in private directory, of course, you can also choose the external sdcard directoryBuilt-in private directory
    1. /data/data/[packagename]/files file cache directory, generally save small file cache, if it is a picture, do not suggest put here, generally put to external card.

      File File = Getfilesdir (); Return to this directory
      Write files to this directory can be like this

      FileOutputStream fos = null;    try {        fos = appontext.openfileoutput (name, context.mode_private);        Fos.write (Content.getbytes ());    } catch (Exception e) {    }finally{        try {            if (null! = Fos) {                fos.close ()            }         } catch (Exception e) {        }    }
    2. /data/data/[packagename]/cache directory, storing some other cached File cache = Getcachedir ();

    3. /data/data/[packagename]/databases, storing the database

    4. /data/data/[packagename]/lib, application of So directory

    5. Sharedpreferences Save for/data/data/[packagename]/shared_prefs applications

Can I create a different directory on my own? OK
Use File Owndatapath = Getdir ("service", context.mode_private);
Use it to create a app_service directory, put what you define

External SDcard Directory
    1. External Cache directory (File sdcache = Getexternalcachedir ();)
      /storage/emulated/0/android/data/[packagename]/cache
      Some of the less important caches or large files are put here, compared to the slice cache

    2. The external File cache directory (File Sdfile = Getexternalfilesdir (null);),
      /storage/emulated/0/android/data/[packagename]/files
      Some of the less important file caches or large files are put here
      Note:/storage/emulated/0/android/data/[packagename] After android2.2, it will be uninstalled after the app is uninstalled. So there is no need to clean up the cache with what the software cleans.

PS: Now the phone supports external Mount T card, how to access the external T card directory?
    1. can refer to!http://stackoverflow.com/questions/5694933/find-an-external-sd-card-location

File save directory for Android app

Related Article

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.