盒子
盒子
Posts List
  1. 一.Environment
    1. Environment.getDataDirectory
    2. Environment.getDownloadCacheDirectory
    3. Environment.getExternalStorageDirectory
    4. Environment.getExternalStoragePublicDirectory
    5. Environment.getRootDirectory
  2. 二.context
    1. context.getFilesDir
    2. context.getExternalFilesDir
    3. context.getCacheDir
    4. context.getExternalCacheDir
  3. 三.SharePreference

android基础(3) 存储位置

一.Environment

Environment系列存储位置都与包名无关,是所有应用公共的存储空间。

Environment.getDataDirectory

/data

Environment.getDownloadCacheDirectory

/cache

Environment.getExternalStorageDirectory

/storage/emulated/0

Environment.getExternalStoragePublicDirectory

/storage/emulated/0/DCIM

Environment.getRootDirectory

/system

二.context

context获取的存储位置,基本都与应用有关,因此都会有包名在路径中,假定包名为
com.example.hch.androidstudy

context.getFilesDir

/data/data/com.example.hch.androidstudy/files

context.getExternalFilesDir

/storage/emulated/0/Android/data/com.example.hch.androidstudy/files/DCIM

context.getCacheDir

/data/data/com.example.hch.androidstudy/cache

context.getExternalCacheDir

/storage/emulated/0/Android/data/com.example.hch.androidstudy/cache

三.SharePreference

数据以xml形式存储在
/data/data/com.example.hch.androidstudy/shared_prefs

支持一下
扫一扫,支持牛头码农