Code Monkey home page Code Monkey logo

storagedescption's Introduction

system

data

storage

system

通过Environment.getRootDirectory()获取,内部存储了framework等系统需要的文件,该文件只拥有可读权限,获取并显示其中的文件列表

该文件占用的大小约为2G /system

data

Android把内存分为Internal Storage 和 External Storage,即为内部存储和外部存储(SD卡存储)

Internal Storage中的文件通过 Environment.getDataDirectory()获取 /data 目录的文件 Context.getFilesDir().getParentFile()获取 /data/user/0/包名 目录的文件

应用内分配的存储空间 /data/user/0/包名 位于 /data 中,解析 /data/user/0/包名 的文件空间如下: 读取到的总空间大小为16M,但是可用空间读取到接近6G,猜测分配给应用的私有空间会动态分配,并且这个读取到的可用空间是变化的 /data/user/0/包名 中的文件结构如下所示: files文件通过Context.getFilesDir()获取,其作用是存放应用私有数据,只有本应用有读写的权限,随应用的删除而删除

cache文件通过Context.getCacheDir()获取,其作用是存储缓存数据,可被手机管家等将其中的数据删除

应用默认自带读写权限

开发中应用对 /data/user/0/包名 有读写权限,但是对 /data/user/0 没有读写权限,同时,对于 /data 我也无法获取其读写权限!

storage

通过Environment.getExternalStorageDirectory()获取根目录 /storage/emulated/0 ,用于存储应用的私有、公开数据,系统级的公开数据等,该目录就是手机文件管理器打开的文件根目录,其结构可能如下: 其中Download、DCIN、Pictures等就是系统级的公开信息存储位置,合理的使用这些文件,在使用Pictures的时候应该在其中创建应用命名的文件夹,便于管理自己应用产生的文件

其中Android文件夹中的data中的包名下就是应用的外部文件应用私有文件区域,其下基本结构如下:

应用可以在files中创建存储文件,文件为应用私有,应用卸载时会随之删除,可通过FileProvider等对外提供文件的短暂访问

对于 /storage/emulated/0 内存空间,如下:

我的手机是64G的内存,但是读取到的总内存只有53G也就是用户可用的部分

Note:运行结果受手机影响!

storagedescption's People

Contributors

piscesye avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.