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之前,让我们先看看什么是测试. 一.测试的构成 其实说白了,测试就是在特定的环境.特定的场景下.执行特定的行为,然后确认结果与期望的是否一致. 就拿最常见的登录来说,完成一次正 ...
随机推荐
- Codeforces Round#1
A. Theatre Square 题目大意:有一个长宽为m和n的广场,用边长为a的正方形去铺盖,问铺满最少需要多少正方形 题解:题目分解为用长度为a的线条分别去覆盖长度为m和n的线条,计算两者的乘积 ...
- solaris 操作系统配置联网
1. 设置主机名: etc/hostname.vmxnet0 hannick 2.设置主机名和ip地址的映射: etc/hosts 127.0.0.1 localhost 192.108.1.123 ...
- 一步一步学android之布局管理器——LinearLayout
线性布局是最基本的一种布局,在基本控件篇幅中用到的都是LinearLayout,线性布局有两种方式,前面也有用到,一种是垂直的(vertical),一种是水平的(horizontal).我们同样来看下 ...
- JavaScript属性中的offsetLeft、offsetWidth、clientWidth、scrollLeft、scrollWidth、innerWidth
1.offsetLeft和offsetTop 只读属性,返回当前元素与父辈元素之间的距离(不包括边框).其中父辈元素的取法是有门道的: (1).若父辈元素中有定位的元素,那么就返回距离当前元素最近的定 ...
- windows下fitness python版本安装测试
FitNesse介绍¶ FitNesse是一套软件开发协作工具. 伟大的软件需要协作和交流,FitNesse可以帮助大家加强软件开发过程中的协作.能够让客户.测试人员和开发人员了解软件要做成什么样,自 ...
- 理解Python的with as语句
简单的说, with open(filepath, 'wb') as file: file.write("something") 等价于: file = open(filepath ...
- Ajax 生成流文件下载 以及复选框的实现
JQuery的ajax函数的返回类型只有xml.text.json.html等类型,没有“流”类型,所以我们要实现ajax下载,不能够使用相应的ajax函数进行文件下载.但可以用js生成一个form, ...
- 设置Firefox禁用js缓存
让firefox禁用缓存 让Firefox不再使用缓存网站开发时经常会有这样的疑问:为什么修改了代码,刷新了页面还是没有看到改动呢? 其实,可能只是你的Firefox并没有去下载你更新了的文件. 这时 ...
- Understanding and Selecting a SIEM/LM: Correlation and Alerting
Continuing our discussion of core SIEM and Log Management technology, we now move into event correla ...
- Tomcat embed
http://www.iflym.com/index.php/code/use-embeded-tomcat-to-javaee-start-tomcat.html http://java.dzone ...