Android外部存储 - 官方文档解读
预备知识:External Storage Technical Information
摘要:
"The
WRITE_EXTERNAL_STORAGE permission must only grant write access to the
primary external storage on a device. Apps must not be allowed to write
to secondary external storage devices, except in their package-specific
directories as allowed by synthesized permissions. Restricting writes in
this way ensures the system can clean up files when applications are
uninstalled."
"Starting in Android 4.4, multiple external storage
devices are surfaced to developers through
Context.getExternalFilesDirs(), Context.getExternalCacheDirs(), and
Context.getObbDirs()."
Q&A:
*Primary external storage? Secondary external storage?
-参考source.android.com/devices/tech/storage/config-example.html
有的手机不支持SD卡扩展(如Nexus 4),所以没有secondary;
有的手机支持(如Note 3),所以区分primary和secondary。
是否primary,由android/frameworks/base/core/res/res/xml/storage_list.xml决定。
一般地,primary是由内部存储(internal storage,比如NAND eMMC)中划分一部分为外部存储(external
storage);mountPoint为"/storage/sdcard0";subsystem为"fuse",也就是由FUSE
daemon模拟的。
secondary是可插拔(removable)的SD卡,mountPoint为"/storage/sdcard1"或"/storage/extSdCard";subsystem为"sd"。
*什么是package-specific directories?
-如package名为com.app.foo在primary/secondary的Android/data/com.app.foo目录。
/Android/data目录是由android/system/core/sdcard.c::handle_mkdir被调用时创建的,并同时新建.nomedia文件。
Context.getExternalFilesDirs(), Context.getExternalCacheDirs()会触发创建package-specific directories。
而Context.getObbDirs()会触发创建/Android/obb/。
*app对于SD卡的write权限范围分别在哪儿?
-在Note3上试验:
1.不声明WRITE_EXTERNAL_STORAGE情况下,不管是primary还是secondary,在package目录下能够写文件,在Android/data/下都会抛出IOException;
2.声明后,primary能够在Android/data/目录下写文件,而secondary依然IOException。
"For
example, the app with package name com.example.foo can now freely
access Android/data/com.example.foo/ on external storage devices with no
permissions."
"Specifically, configuration and log files should only be stored on internal storage where they can be effectively protected."
Android外部存储 - 官方文档解读的更多相关文章
- Cuda 9.2 CuDnn7.0 官方文档解读
目录 Cuda 9.2 CuDnn7.0 官方文档解读 准备工作(下载) 显卡驱动重装 CUDA安装 系统要求 处理之前安装的cuda文件 下载的deb安装过程 下载的runfile的安装过程 安装完 ...
- 【Java架构:基础技术】一篇文章搞掂:Spring Boot 官方文档解读
本文篇幅较长,建议合理利用右上角目录进行查看(如果没有目录请刷新). 本文内容大部分是翻译和总结官方文档,可以到https://docs.spring.io/spring-boot/docs查看(此地 ...
- FluentValidation:C#后端输入验证框架的官方文档解读
参照 FluentValidation 的官方文档写的例子,方便日后查看和使用. 原文:https://github.com/JeremySkinner/FluentValidation/wiki H ...
- Python 官方文档解读(2):threading 模块
使用 Python 可以编写多线程程序,注意,这并不是说程序能在多个 CPU 核上跑.如果你想这么做,可以看看关于 Python 并行计算的,比如官方 Wiki. Python 线程的主要应用场景是一 ...
- Google android开发者 中国官方文档开放了呀
Google官方开发文档地址 包括 android , android TV
- android自定义控件(一) 官方文档的翻译
构建自定义组件 Android中,你的应用程序程序与View类组件有着一种固定的联系,例如按钮(Button).文本框(TextView),可编辑文本框(EditText),列表框(ListView) ...
- Python 官方文档解读(1):66 个内置函数
Python 解释器 (CPython 3.7)内置有 66 个函数,这些函数在任何时刻都是可用的.此文是为了对这 66 个函数进行简单的梳理,便于以后可能用到它们时能想到. 1. abs(x) 返回 ...
- 微信小程序开发官方文档解读
创建页面 在这个教程里,我们有两个页面,index 页面和 logs 页面,即欢迎页和小程序启动日志的展示页,他们都在 pages 目录下.微信小程序中的每一个页面的[路径+页面名]都需要写在 app ...
- 【pytest官方文档】解读fixtures - 1.什么是fixtures
在深入了解fixture之前,让我们先看看什么是测试. 一.测试的构成 其实说白了,测试就是在特定的环境.特定的场景下.执行特定的行为,然后确认结果与期望的是否一致. 就拿最常见的登录来说,完成一次正 ...
随机推荐
- POJ2352:Stars
题目 Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34016 Accepted: 14839 Descri ...
- Is it possible to implement a Firebug-like “inspect element” DOM element highlighter with client-side JavaScript?
Is it possible to implement a Firebug-like "inspect element" DOM element highlighter with ...
- Uber 司机有话说:你以为当个 Uber 司机很轻松?大错特错!
Uber 最近的负面新闻越来越多.各方成员都在抨击.斥责.揭露 Uber 公司的各种黑幕.今天,来自 Uber 公司的司机为您讲述咱「拼车老司机」自己的故事.你以为开着自己的私家车出去满城市的晃悠接客 ...
- java的抽象类
现实世界中,人们表征世界时,会把现实世界中的很多类具有相同特征的事物归为一个抽象类.比如水果是许多植物果实的总称,我们可以定义一个苹果类.定义一个西瓜类,可以实例化一个苹果对象,可以实例化一个西瓜对象 ...
- XGPush集成(信鸽集成)demo
#import "AppDelegate.h" #import "XGPush.h" #import "XGSetting.h" #defi ...
- PowerShell Remove all user defined variable in PowerShell
When PS scripts executes, it is possibly create much user defined variables. So, sometimes these var ...
- web api 开发之 filter
1.使用filter之前应该知道的(不知道也无所谓,哈哈!) 谈到filter 不得不先了解下aop(Aspect Oriented Programming)面向切面的编程.(度娘上关于aop一大堆 ...
- javascript学习笔记(window .alert 是什么)
<script language="javascript"> var abc="25"; window .alert(abc); </scri ...
- XML中SystemID和PublicID的区别
http://hi.baidu.com/binboot007/item/1533f91d52113d7c7b5f259c http://supportweb.cs.bham.ac.uk/documen ...
- 盘点:移动服务 #AzureChat
感谢大家帮助我们顺利推出史无前例的 #AzureChat.移动服务和 Notification Hub 是 Windows Azure 平台上令人振奋的服务.我们很高兴能借这次在线讨论的机会,倾听各位 ...