Android存储路径最全总结

Logger.i("1、" + Environment.getRootDirectory()
                + ";2、" + Environment.getDataDirectory()
                + ";3、" + Environment.getDownloadCacheDirectory()
                + ";4、" + Environment.getExternalStorageDirectory()
                + ";5、" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
                + ";6、" + App.getInstance().getContext().getExternalFilesDir(null)
                + ";7、" + App.getInstance().getContext().getFilesDir()
                + ";8、" + App.getInstance().getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
                + ";9、" + App.getInstance().getContext().getExternalCacheDir()
                + ";10、" + App.getInstance().getContext().getCacheDir()
                + ";11、" + App.getInstance().getContext().getFileStreamPath("custom1")
                + ";12、" + App.getInstance().getContext().getObbDir()
                + ";13、" + App.getInstance().getContext().getDir("custom2", Context.MODE_PRIVATE)
        );
编号方法路径备注
1Environment.getRootDirectory()/system
2Environment.getDataDirectory()/data
3Environment.getDownloadCacheDirectory()/cache
4Environment.getExternalStorageDirectory()/storage/emulated/0
5Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)/storage/emulated/0/Movies
6App.getInstance().getContext().getExternalFilesDir(null)/storage/emulated/0/Android/data/com.prprlive.gugu/files
7App.getInstance().getContext().getFilesDir()/data/data//data/data/com.prprlive.gugu/files
8App.getInstance().getContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)/storage/emulated/0/Android/data/com.prprlive.gugu/files/Download
9App.getInstance().getContext().getExternalCacheDir()/storage/emulated/0/Android/data/com.prprlive.gugu/cache
10App.getInstance().getContext().getCacheDir()/data/data/com.prprlive.gugu/cache
11App.getInstance().getContext().getFileStreamPath(“custom1”)/data/data/com.prprlive.gugu/files/custom1
12App.getInstance().getContext().getObbDir()/storage/emulated/0/Android/obb/com.prprlive.gugu
13App.getInstance().getContext().getDir(“custom2”, Context.MODE_PRIVATE)/data/data/com.prprlive.gugu/app_custom2

待完善:getDatabasePath(String Name),getNoBackupFilesDir(),getCodeCacheDir(),后两个是API21新增的方法
以上内容中Logger.i是自己封装的Log打印方法,App.getInstance().getContext()是Application中提供的Context
测试机型:模拟器 系统:Android 5.1.1 在不同的系统上面获取到的路径可能存在差异。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值