Android系統文件目錄路徑說明


系統數據存儲路徑,如下:其中應用程序包名為:com.spt

ContextWrapper類中,包含以下方法:

1. getFilesDir() --> 內部存儲

    @Override
    public File getFilesDir() {
        return mBase.getFilesDir();
    }

k86m_QC機器上數據存儲路徑:/data/data/com.spt/files

華為手機上數據存儲路徑:/data/data/com.spt/files

2. getExternalFilesDir(String type) 參數指定為:Environment.DIRECTORY_PICTURES --> 外部存儲

    @Override
    public File getExternalFilesDir(String type) {
        return mBase.getExternalFilesDir(type);
    }

k86m_QC機器上數據存儲路徑:/storage/sdcard0/Android/data/com.spt/files/Pictures

華為手機上數據存儲路徑:/storage/emulated/0/Android/data/com.spt/files/Pictures

3. getCacheDir() --> 內部存儲

    @Override
    public File getCacheDir() {
        return mBase.getCacheDir();
    }

k86m_QC機器上數據存儲路徑:/data/data/com.spt/cache

華為手機上數據存儲路徑:/data/data/com.spt/cache

4. getExternalCacheDir() --> 外部存儲

    @Override
    public File getExternalCacheDir() {
        return mBase.getExternalCacheDir();
    }

k86m_QC機器上數據存儲路徑:/storage/sdcard0/Android/data/com.spt/cache

華為手機上數據存儲路徑:/storage/emulated/0/Android/data/com.spt/cache

 

Environment類中,包含以下方法:

1. getDataDirctory()

    /**
     * Return the user data directory.
     */
    public static File getDataDirectory() {
        return DATA_DIRECTORY;
    }

k86m_QC機器上數據存儲路徑:/data

華為手機上數據存儲路徑:/data

2. getDownLoadCacheDirectory()

    /**
     * Return the download/cache content directory.
     */
    public static File getDownloadCacheDirectory() {
        return DOWNLOAD_CACHE_DIRECTORY;
    }

k86m_QC機器上數據存儲路徑:/cache

華為手機上數據存儲路徑:/cache

3. getExternalStorageDirectory()

    /**
     * Return the primary external storage directory. This directory may not
     * currently be accessible if it has been mounted by the user on their
     * computer, has been removed from the device, or some other problem has
     * happened. You can determine its current state with
     * {@link #getExternalStorageState()}.
     * <p>
     * <em>Note: don't be confused by the word "external" here. This directory
     * can better be thought as media/shared storage. It is a filesystem that
     * can hold a relatively large amount of data and that is shared across all
     * applications (does not enforce permissions). Traditionally this is an SD
     * card, but it may also be implemented as built-in storage in a device that
     * is distinct from the protected internal storage and can be mounted as a
     * filesystem on a computer.</em>
     * <p>
     * On devices with multiple users (as described by {@link UserManager}),
     * each user has their own isolated external storage. Applications only have
     * access to the external storage for the user they're running as.
     * <p>
     * In devices with multiple "external" storage directories, this directory
     * represents the "primary" external storage that the user will interact
     * with. Access to secondary storage is available through
     * <p>
     * Applications should not directly use this top-level directory, in order
     * to avoid polluting the user's root namespace. Any files that are private
     * to the application should be placed in a directory returned by
     * {@link android.content.Context#getExternalFilesDir
     * Context.getExternalFilesDir}, which the system will take care of deleting
     * if the application is uninstalled. Other shared files should be placed in
     * one of the directories returned by
     * {@link #getExternalStoragePublicDirectory}.
     * <p>
     * Writing to this path requires the
     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission,
     * and starting in read access requires the
     * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
     * which is automatically granted if you hold the write permission.
     * <p>
     * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, if your
     * application only needs to store internal data, consider using
     * {@link Context#getExternalFilesDir(String)} or
     * {@link Context#getExternalCacheDir()}, which require no permissions to
     * read or write.
     * <p>
     * This path may change between platform versions, so applications should
     * only persist relative paths.
     * <p>
     * Here is an example of typical code to monitor the state of external
     * storage:
     * <p>
     * {@sample
     * development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
     * monitor_storage}
     *
     * @see #getExternalStorageState()
     * @see #isExternalStorageRemovable()
     */
    public static File getExternalStorageDirectory() {
        throwIfUserRequired();
        return sCurrentUser.getExternalDirsForApp()[0];
    }

k86m_QC機器上數據存儲路徑:/storage/sdcard0

華為手機上數據存儲路徑:/storage/emulated/0

4. getRootDirectory()

    /**
     * Return root of the "system" partition holding the core Android OS.
     * Always present and mounted read-only.
     */
    public static File getRootDirectory() {
        return DIR_ANDROID_ROOT;
    }

k86m_QC機器上數據存儲路徑:/system

華為手機上數據存儲路徑:/system

5. getExternalStoragePublicDirectory(String type)

    /**
     * Get a top-level public external storage directory for placing files of
     * a particular type.  This is where the user will typically place and
     * manage their own files, so you should be careful about what you put here
     * to ensure you don't erase their files or get in the way of their own
     * organization.
     * 
     * <p>On devices with multiple users (as described by {@link UserManager}),
     * each user has their own isolated external storage. Applications only
     * have access to the external storage for the user they're running as.</p>
     *
     * <p>Here is an example of typical code to manipulate a picture on
     * the public external storage:</p>
     * 
     * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
     * public_picture}
     * 
     * @param type The type of storage directory to return.  Should be one of
     * {@link #DIRECTORY_MUSIC}, {@link #DIRECTORY_PODCASTS},
     * {@link #DIRECTORY_RINGTONES}, {@link #DIRECTORY_ALARMS},
     * {@link #DIRECTORY_NOTIFICATIONS}, {@link #DIRECTORY_PICTURES},
     * {@link #DIRECTORY_MOVIES}, {@link #DIRECTORY_DOWNLOADS}, or
     * {@link #DIRECTORY_DCIM}.  May not be null.
     * 
     * @return Returns the File path for the directory.  Note that this
     * directory may not yet exist, so you must make sure it exists before
     * using it such as with {@link File#mkdirs File.mkdirs()}.
     */
    public static File getExternalStoragePublicDirectory(String type) {
        throwIfUserRequired();
        return sCurrentUser.buildExternalStoragePublicDirs(type)[0];
    }

k86m_QC機器上數據存儲路徑:/storage/sdcard0/Pictures

華為手機上數據存儲路徑:/storage/emulated/0/Pictures

Internal Storage和External Storage的區別:

getFilesDir() --> 內部存儲 /data/data/com.spt/files

getCacheDir() --> 內部存儲 /data/data/com.spt/cache

內部存儲,對應的是特定的應用程序,如上所述指的是包名為:com.spt應用程序

getExternalFilesDir(String type) --> 外部存儲 /storage/sdcard0/Android/data/com.spt/files/Pictures

getExternalCacheDir() --> 外部存儲 /storage/sdcard0/Android/data/com.spt/cache

getExternalStoragePublicDirectory(String type) --> 外部存儲 /storage/sdcard0/Pictures

getExternalStorageDirectory() --> 外部存儲 /storage/sdcard0

1. 外部存儲,對應的是/storage/sdcard0/目錄;

2. private files:如果需要在卸載應用程序時,刪除所有該應用程序的外部存儲(同時,該數據是本應用程序私有的),可以使用:getExternalFilesDir(String type)目錄,帶有應用程序包名;

3. public files可以存放在:getExternalStoragePublicDirectory(String type)

P.S. 

對於特定的智能后視鏡設備:Flash --> /mnt/sdcard 硬盤大小 外部存儲路徑:/storage/sdcard1" 外設的存儲設備


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM