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" 外设的存储设备

时间: 2024-08-02 06:58:56

Android系统文件目录路径说明的相关文章

android 系统log文件路径

手机的默认的日志目录: /data/local/tmp/* /data/tmp/* /data/system/usagestats/* /data/system/appusagestates/* /data/system/dropbox/* /data/tombstones/* /data/anr/* logcat的日志在 /dev/log/main 有/data/local/log目录的,可以保存3-4天的log. android 系统log文件路径

Android系统级技巧合集

Android系统级技巧合集(随时更新) #转载请注明来源# 1.高通骁龙系列查看CPU体质等级 CPU体质,即为CPU在工作频率下的电压.同一批次的CPU体质各有不同,体质越高,代表该颗CPU可在更高的频率下稳定工作,且在相同频率下工作时功耗相比同批次体质差的CPU要控制得更好. 以搭载高通骁龙801的小米4(OS:第三方原生Android)为例,可在/sys下的文件中查找到描述该CPU体质的文件. 路径为:/sys/module/clock_krait_8974/parameters/ 在该

Android系统关机或重启的几种实现方式

前阵子工作上遇到一些关于Android系统关机或重启的系统修改,于是,做了一些尝试,也搜集了一下资料,现在整理一下,做一些总结,方便学习或者日后工作的需要. 默认的SDK并没有提供应用开发者直接的Android系统关机或重启的API接口,一般来讲,实现Android系统的关机或重启,需要较高的权限(系统权限甚至Root权限).所以,在一般的APP中,如果想要实现关机或重启功能,要么是在App中声明系统权限,要么是通过某种“间接”的方式,比如广播或反射,来间接实现系统关机或重启.再者,就是放在源码

Android系统开发(1)——GCC编译器的编译和安装过程

GCC编译器介绍 GCC编译器(GNG C Compiler)是GNU项目中符合ANSI C标准的编译系统,能够编译C  C++  Object C等语言编写的程序,同时GCC也是一个交叉编译器,特别使用于不同平台的嵌入式开发. GNU: GNU是"GNU is Not Unix"的递归缩写,1984年,史托曼开始GNU项目,这个项目的目的是创建一个自由,开放的Unix操作系统(Free UNIX),刚开始史托曼参考UNIX上面的软件,开发出功能类似的软件,在开发期间并没有看其他软件的

【Android 系统开发】CyanogenMod 13.0 源码下载 编译 ROM 制作 ( 手机平台 : 小米4 | 编译平台 : Ubuntu 14.04 LTS 虚拟机)

作者 : 韩曙亮 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/51592930 手机的两种模式 : 在下面有详细的图片示例; -- Recovery 模式 : 音量键增加 + 电源键, 长按上述组合键, 看到 "MI" 的 LOGO 后即进入 Recovery 模式; -- Fastboot 模式 : 音量键减小 + 电源键, 长按上述组合键, 看到 "FASTBOOT" 后, 即 进入 FA

Android系统中添加一个产品----图文详解

本文本着开源的精神介绍如何向一个Android系统中添加一个产品的整个过程,按照以下过程笔者有理由相信每个将要从事本行业的人都可以完成,其实添加一个产品并不难,难的是对其相关硬件的修改,好了废话不多说. 首先我们要创建一个属于自己产品的目录,这里以WY_device为例,以WY作为产品的名字. 首先从已经存在的产品中拷贝一个以产品的名字为名的.mk文件,修改为自己的.mk文件,在这里为WY.mk 对其进行如下的修改: 然后添加AndroidProducts.mk  这是添加产品的配置文件名路径,

Android系统编译时遇到的几个.mk的疑惑。

在Android4.2的源码Build/prduct_config.mk里面遇到几个疑惑: # Convert a short name like "sooner" into the path to the product # file defining that product. # INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) ifneq ($(current_product_ma

漫谈android系统(7)-log系统1

前言 罗升阳的<Android系统源代码情景分析>一书,有关log是如何显示,那么真的在代码中是如何实现的呢?就该问题我想需要细细分析 bootloader层的log 在firmware中的log是如何产生的,我没有看过firmware的code,不清楚它是如何实现的,这是我的短板,回头得补上!在这里先分析lk中是如何实现的. 从aboot.c着手 相信在源码中看到bootable\bootloader\lk下的app\aboot.c中最常用于打log信息的语句为dprintf.那么它的原型在

Android系统Recovery工作原理之使用update.zip升级过程分析(一)

通过分析update.zip包在具体Android系统升级的过程,来理解Android系统中Recovery模式服务的工作原理.我们先从update.zip包的制作开始,然后是Android系统的启动模式分析,Recovery工作原理,如何从我们上层开始选择system update到重启到Recovery服务,以及在Recovery服务中具体怎样处理update.zip包升级的,我们的安装脚本updater-script怎样被解析并执行的等一系列问题.分析过程中所用的Android源码是gin