"Android" resolves the path of Android

Source: Internet
Author: User

Directory structure:

contents Structure [+]
    1. Internal Path
    2. External path

The paths in Android are mainly divided into internal and external paths.

I. Internal path

The common internal storage paths are:

File f1=environment.getdatadirectory ();///dataFile f2=environment.getdownloadcachedirectory ();///cacheFile f3=environment.getrootdirectory ();///systemFile f4=Context. Getcachedir ();///data/data/com.example.fileexiststest/cacheFile f5=Context. Getdatabasepath ("abc.db");///data/data/com.example.fileexiststest/databases/abc.dbFile f6=Context. Getfilesdir ();///data/data/com.example.fileexiststest/filesFile f7=Context. Getfilestreampath ("Test2.txt");///data/data/com.example.fileexiststest/files/test2.txt


It is important to note that the folders and files stored internally are only visible after the root of the phone, and the files in the internal path are generally read-only.
As can be seen from the above observation, the internal storage of the public cache path under the/cache file, the private cache path under the/data/data/package name/under each private cache path has three subdirectories, respectively, Cache,databases,files. Cache path is used for caching, databases path is to store the database files, the usual use of the Sqllite database is stored in this directory, files is to store other files.

Two. External path

The common external paths are:

File f1=environment.getexternalstoragedirectory ();///storage/emulated/0File f2=environment.getexternalstoragepublicdirectory ("abc");///STORAGE/EMULATED/0/ABCFile f3= This. Getexternalcachedir ();///storage/emulated/0/android/data/com.example.fileexiststest/cacheFile f4= This. Getexternalfilesdir ("test");///storage/emulated/0/android/data/com.example.fileexiststest/files/testFile f5= This. Getobbdir ();///storage/emulated/0/android/obb/com.example.fileexiststest

In the memory of the phone, you can find/storage/emulated/0 this directory, but there is no data, but to see the size of this directory is found to have data, this is because the data is hidden.

The/storage/emulated/0 directory is an externally stored directory.
As you have learned, the memory-stored files are read-only and if you want to write data, you have to save them in the external path.
Both the external path and the memory path have the same structure. It is also divided into common path and private path, the common path can be arbitrarily built files and directories to store data. The format of the private directory is/android/data/package name/. The data of the public path can be accessed by all programs, and the data under the private path is accessible only by the current program.

"Android" resolves the path of Android

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.