Android内部和外部目录

/**
* //用户数据目录。/data
*/
String path1 = Environment.getDataDirectory().getPath();
/**
* //下载缓存内容目录。/cache
*/
String path2 = Environment.getDownloadCacheDirectory().getPath();
/**
* //主要的外部存储目录。 /storage/emulated/0
*/
String path3 = Environment.getExternalStorageDirectory().getPath();
/**
* 外部存储目录很可能当前不能访问,比如这个目录被用户的PC挂载,
* 或者从设备中移除,或者其他问题发生,
* 你可以通过getExternalStorageState()来获取当前状态。
*
* Environment.MEDIA_MOUNTED 等等
*/
String path4 = Environment.getExternalStorageState();

    /**
     * 内部存储上的目录
     * /data/user/0/程序包名/files
     */
    String path6 = this.getFilesDir().getPath();
    /**
     * 内部存储上的目录
     *  /data/user/0/程序包名/cache
     */
    String path7 = this.getCacheDir().getPath();
    /**
     * 应用的在外部存储上的缓存目录。
     * /storage/emulated/0/Android/data/程序包名/cache
     */
    String path8 = this.getExternalCacheDir().getPath();
    /**
     * 应用在外部存储上的目录。
     * /storage/emulated/0/Android/data/程序包名/files/data
     */
    String path = this.getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath();

    /**
     * 应用在外部存储上的目录。
     * /storage/emulated/0/Android/data/程序包名/files
     */
    String path10 = this.getExternalFilesDir("").getAbsolutePath();

    /**
     * 设备的外存是否是用内存模拟的,是则返回true。
     */
    boolean i = Environment.isExternalStorageEmulated();

    /**
     * 设备的外存是否是可以拆卸的,比如SD卡,是则返回true
     */
    boolean a = Environment.isExternalStorageRemovable();

    Log.e("====", path1 + "\n" + path2 + "\n" + path3 + "\n" + path4
            + "\n" + "\n" + path6 + "\n" + path7 + "\n" + path8 + "\n" + path
            + "\n" + path10 + "\n" + i);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值