安卓4.4内存卡系统不可以把内存中的软件移到SD卡上吗

Android 4.4系统中SD存储卡将成“废品”? - 移动开发 - ITeye资讯
相关知识库:
Google去年11月正式发布了Android 4.4,代号为KitKat(奇巧,雀巢的一款巧克力品牌),。
但需要注意的是,该系统可能会让你之前一直正常使用的SD卡变为无用的“摆设”,因为根据新版本的API改进,应用程序将不能再往SD卡中写入文件。
来看Android开发者网站的中的描述:
引用WRITE_EXTERNAL_STORAGE只为设备上的主要外部存储授予写权限,应用程序无法将数据写入二级外部存储设备,除非指定了应用程序允许访问的特定的目录。
这目前只影响双存储设备,如果你的设备有内部存储空间,即通常所说的机身存储(这就是指主要外部存储),那么你的SD卡就是一个二级外部存储设备。
在Android 4.4中,如果你同时使用了机身存储和SD卡,那么应用程序将无法在SD卡中创建、修改、删除数据。比如,你无法使用文件管理器通过无线网络从电脑往SD卡中复制文件了。但是应用程序仍然可以往主存储的任意目录中写入数据,不受任何限制。
Google表示,这样做的目的是,通过这种方式进行限制,系统可以在应用程序被卸载后清除遗留文件。
目前三星已经通过OTA向部分手机发送了Android 4.4的更新,已经有Note3用户抱怨FX文件管理器现在不能往SD卡中复制内容了。
获得系统的ROOT权限是一个解决方法。
很显然,这是针对用户的解决办法,但是并不是所有的用户都愿意进行ROOT,那么需要SD卡写入权限的开发者该如何做呢?
XDA论坛已经有大神给出了解决方案——在应用中嵌入一段代码,这段代码作用是在Android 4.4+设备上,如果其他方式写入失败,则将数据写入二级存储设备。
详细方案:
* Copyright (C) 2014 NextApp, Inc.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
package nextapp.
import java.io.F
import java.io.IOE
import java.io.OutputS
import android.content.ContentR
import android.content.ContentV
import android.net.U
import android.provider.MediaS
* Wrapper for manipulating files via the Android Media Content Provider. As of Android 4.4 KitKat, applications can no longer write
* to the "secondary storage" of a device. Write operations using the java.io.File API will thus fail. This class restores access to
* those write operations by way of the Media Content Provider.
* Note that this class relies on the internal operational characteristics of the media content provider API, and as such is not
* guaranteed to be future-proof. Then again, we did all think the java.io.File API was going to be future-proof for media card
* access, so all bets are off.
* If you're forced to use this class, it's because Google/AOSP made a very poor API decision in Android 4.4 KitKat.
* Read more at /+TodLiebeck/posts/gjnmuaDM8sn
* Your application must declare the permission "android.permission.WRITE_EXTERNAL_STORAGE".
public class MediaFile {
private final F
private final ContentResolver contentR
private final Uri filesU
private final Uri imagesU
public MediaFile(ContentResolver contentResolver, File file) {
this.file =
this.contentResolver = contentR
filesUri = MediaStore.Files.getContentUri("external");
imagesUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
* Deletes the file. Returns true if the file has been successfully deleted or otherwise does not exist. This operation is not
* recursive.
public boolean delete()
throws IOException {
if (!file.exists()) {
boolean directory = file.isDirectory();
if (directory) {
// Verify directory does not contain any files/directories within it.
String[] files = file.list();
if (files != null && files.length & 0) {
String where = MediaStore.MediaColumns.DATA + "=?";
String[] selectionArgs = new String[] { file.getAbsolutePath() };
// Delete the entry from the media database. This will actually delete media files (images, audio, and video).
contentResolver.delete(filesUri, where, selectionArgs);
if (file.exists()) {
// If the file is not a media file, create a new entry suggesting that this location is an image, even
// though it is not.
ContentValues values = new ContentValues();
values.put(MediaStore.Files.FileColumns.DATA, file.getAbsolutePath());
contentResolver.insert(imagesUri, values);
// Delete the created entry, such that content provider will delete the file.
contentResolver.delete(filesUri, where, selectionArgs);
return !file.exists();
public File getFile() {
* Creates a new directory. Returns true if the directory was successfully created or exists.
public boolean mkdir()
throws IOException {
if (file.exists()) {
return file.isDirectory();
// Create a media database entry for the directory. This step will not actually cause the directory to be created.
values = new ContentValues();
values.put(MediaStore.Files.FileColumns.DATA, file.getAbsolutePath());
contentResolver.insert(filesUri, values);
// Create an entry for a temporary image file within the created directory.
// This step actually causes the creation of the directory.
values = new ContentValues();
values.put(MediaStore.Files.FileColumns.DATA, file.getAbsolutePath() + "/temp.jpg");
uri = contentResolver.insert(imagesUri, values);
// Delete the temporary entry.
contentResolver.delete(uri, null, null);
return file.exists();
* Returns an OutputStream to write to the file. The file will be truncated immediately.
public OutputStream write()
throws IOException {
if (file.exists() && file.isDirectory()) {
throw new IOException("File exists and is a directory.");
// Delete any existing entry from the media database.
// This may also delete the file (for media types), but that is irrelevant as it will be truncated momentarily in any case.
String where = MediaStore.MediaColumns.DATA + "=?";
String[] selectionArgs = new String[] { file.getAbsolutePath() };
contentResolver.delete(filesUri, where, selectionArgs);
ContentValues values = new ContentValues();
values.put(MediaStore.Files.FileColumns.DATA, file.getAbsolutePath());
Uri uri = contentResolver.insert(filesUri, values);
if (uri == null) {
// Should not occur.
throw new IOException("Internal error.");
return contentResolver.openOutputStream(uri);
不能因为蛋疼就直接把蛋切了啊,这做法也太激进了吧
标题党……
应该这样,现在的SD卡上的目录让人蛋疼,不过也一刀切的太厉害了,应用之间共享文档不方便,搞的和苹果一样了,应有文档、音频、视频、照片等几个统一目录,给这几个统一目录分别设置相应的读写权限。
dsjt 写道安卓手机SD卡根目录下满屏幕的APP文档文件夹确实蛋疼。蛋疼,那也不能这样设计啊。这样设计不太蛋疼。
安卓手机SD卡根目录下满屏幕的APP文档文件夹确实蛋疼。
不错~谢谢分享如何将Android软件从手机内存转移到存储卡-ROM下载之家官网
当前位置: && &- &
如何将Android软件从手机内存转移到存储卡
  Android系统只能把软件安装在手机内存里,使本来就不大的手机内存显得捉襟见肘。面对越来越少的手机内存空间,不得不对已经安装的软件痛下杀手。你是否还在安装与卸载之间纠结?别纠结啦,小编今天带来了解决方法,方法如下:
  Tips:存储器分为随机存储器(RAM)和只读存储器(ROM)两种。手机ROM相当于PC上的硬盘,用于存储手机操作系统和软件,也叫FLASH
ROM,决定手机存储空间的大小。手机RAM相当于PC的内存,其大小决定手机的运行速度。
  要把大象装冰箱里总共分三步,而Android系统中把软件安装到SD卡上,比这还简单,两步就够了:
  一、存储卡分区
  首先我们需要对手机SD卡进行分区,分一个FAT32分区和一个Ext3分区,FAT32分区用于正常存储图片、音乐、视频等资料,而Linux格式的Ext3分区就是用于扩容安装软件的分区。以笔者的2G
SD卡为例,FAT32分区1.35GB,Ext3分区494MB。下载并安装Acronis Disk Director
Suite软件。将手机SD卡装入读卡器并连接电脑,然后运行Acronis Disk Director Suite软件。
  1.FAT32分区。
  找到代表SD卡的磁盘分区,点击右键,选择“删除”命令,删除已有分区。当成为“未分配”分区时,点击右键,选择“创建分区”,在弹出的对话框中,文件系统选择:FAT32,创建为“主分区”,设置好分区大小1.35GB,点击确定按钮。
  2.Ext3分区。
  在剩余的494MB分区上,点击右键,选择“创建分区”,在弹出的对话框中,文件系统选择:Ext3,创建为“主分区”,设置好分区大小494MB,点击确定按钮。
  3.确认分区。
  上述分区设定完成后,软件只是记录了分区操作,并没有真正在SD卡上进行分区。点击软件工具栏中的“提交”按钮,确认执行分区操作,提示“操作成功完成”说明分区成功了。
  二、将软件移动到SD卡
  存储卡分区完成后我们只需要把系统默认的软件安装目录/data/app转移到SD卡的Ext3分区上,然后通过ln命令建立软链接,使系统自动把软件安装到SD卡上,达到节省手机内存空间的目的。
  将存储卡装回手机,重新启动,使系统识别到Ext3分区。在手机上运行超级终端,依次输入以下命令来验证系统是否识别了Ext3分区:
  su (会提示高级权限授权,选择“总是同意”)
  busybox df –h
  如果显示的列表中有/dev/block/mmcblk0p2的信息说明系统已成功识别了Ext3分区。
  然后依次输入以下命令将/data/app目录转移到SD卡的Ext3分区:
  cp –a /data/app /system/sd/
  (将/data/app目录复制到/system/sd/下)
  rm –r /data/app
  (删除/data/app目录)
  ln –s /system/sd/app /data/app
  (建立软链接)
  Reboot
  (重启手机)
  重启之后,手机上安装的所有软件就全部转移到了SD卡上,看看你的手机可用空间是不是增大了。以后再安装软件也是直接安装到SD卡上,不用担心空间
不足的问题了,而且这样做还有一个好处,刷新ROM后,以前安装过的软件并没有被清除,还保存在SD卡上,输入下列命令就可以轻松恢复,不用再一一安装
了,非常方便实用。
  (取得高级权限)
  cd /data
  (进入/data目录)
  cp –a app /system/sd/app
  (将app目录中的内容复制到/system/sd/app目录)
  rm –r app
  (删除app目录)
  ln –s /system/sd/app /data/app
  (建立软链接)
  reboot
  (重新启动)
  扩容效果体验:
  刷新ROM后未安装任何软件,手机可用空间为87MB,安装若干软件后,可用空间下降为73MB。将软件目录转移到SD卡上后,可用空间变为
80MB。可能有的“电筒”会有疑惑,为什么没恢复到87MB呢?这是因为我们只是将软件移动到了SD卡上,而软件的缓存数据仍然会占用手机内存,所以手
机内存还是会下降。当然软件的缓存数据也可以移动到SD卡上,但这样会拖慢软件运行速度,所以不推荐大家使用。
  注意事项:
  1.软件移动到SD卡上后,原有的部分桌面插件会无法正常显示,删除后,重新加入桌面即可。
  2.SD卡的Ext3分区可以视为手机硬件的一部分,移除SD卡后,安装的软件将无法运行。插入SD卡,重新启动手机即可正常使用。
热门刷机包top10
热门刷机技巧top10
热门ROM资讯top10
热门手机刷机包
热门刷机包top10
热门刷机技巧top10
热门ROM资讯top10
热门手机刷机包
刷机包下载经验2041 米
在线时间26 小时
版本V8.5.1.0.NBCCNED
积分 2229, 距离下一级还需 2771 积分
积分 2229, 距离下一级还需 2771 积分
机型小米Max
签到次数12
MIUI版本V8.5.1.0.NBCCNED
手机先ROOR
下载安装RE文件管理器(我用的是2.2经典版。要的上网搜一下就有了)
R.E管理器挂载为读写,打开/system/etc/permissions目录,找到platform.xml文件,长按,在菜单中选择“在文本编辑器中打开”。
查找代码:
&permissionname=&android.permission.WRITE_EXTERNAL_STORAGE& &
&group gid=&sdcard_r& /&
(此行代码有些机型没有, 没有的可以忽略)
&group gid=&sdcard_rw& /&
&/permission&
将之改为:
&permissionname=&android.permission.WRITE_EXTERNAL_STORAGE& &
&group gid=&sdcard_r& /&
&group gid=&sdcard_rw& /&
&groupgid=&media_rw& /&
&/permission&
(注意:段首对齐,&media_rw&和/&之间有空格。或可复制上一行代码进行修改。)
然后保存并退出。
完成上面两步后重启手机,你会发现可以往外置存储卡(SD卡)创建、修改、删除数据了。
很多人一直在论坛问。但居然没人知道…我今天打这帖打了三次……第一次去微云复制RE管理器2.2版的安装包下载链接不小心把后台清了…于是帖子没了…第二了发了后说我有敏感词……又没了…这是第三次!
分享到微信朋友圈
打开微信,点击底部的“发现”,使用 “扫一扫” 即可将网页分享到我的朋友圈。
经验2041 米
在线时间26 小时
版本V8.5.1.0.NBCCNED
积分 2229, 距离下一级还需 2771 积分
积分 2229, 距离下一级还需 2771 积分
机型小米Max
签到次数12
MIUI版本V8.5.1.0.NBCCNED
忘了说了。每次更新后这个新加的代码就会消失!
但是这个加代码十分简单。把代码储存 方法记住就行。
经验2686 米
在线时间123 小时
版本V8.1.3.0.LHNCNDI
积分 3010, 距离下一级还需 1990 积分
积分 3010, 距离下一级还需 1990 积分
机型红米Note3
签到次数34
MIUI版本V8.1.3.0.LHNCNDI
通过手机发布
这样做的效果是什么
在线时间0 小时
版本V7.5.1.0.KHICNDE
积分 32, 距离下一级还需 18 积分
积分 32, 距离下一级还需 18 积分
机型红米Note 4G版
MIUI版本V7.5.1.0.KHICNDE
什么 完成上面两步后重启手机,
经验2041 米
在线时间26 小时
版本V8.5.1.0.NBCCNED
积分 2229, 距离下一级还需 2771 积分
积分 2229, 距离下一级还需 2771 积分
机型小米Max
签到次数12
MIUI版本V8.5.1.0.NBCCNED
什么 完成上面两步后重启手机,
有什么问候
经验1696 米
在线时间13 小时
积分 1751, 距离下一级还需 249 积分
积分 1751, 距离下一级还需 249 积分
机型红米手机 TD版
签到次数15
MIUI版本7.2.9
原版的程序好象没有你的那些标示,只有符号。能写标准些吗?
新版论坛APP
更新新版APP
“澎湃S1 ”芯片纪念勋章
参与活动回帖可得
MIUI 300周
MIUI 300周更新纪念勋章
MIUI六周年
MIUI六周年纪念勋章
APP 1000万
MIUI论坛APP注册用户突破1000万纪念勋章
小火箭勋章
神舟11号 话题活动
MIUI五周年
MIUI五周年纪念勋章
已关注微信
关注腾讯微博
已关注腾讯微博
小米众筹2周年
参加回帖活动
小米7周年勋章
2017米粉节晒单赢专属勋章
参与红米Note 4X活动
2017年小金鸡勋章
回复2016年度评选活动贴
圣诞节勋章
参与圣诞活动
Copyright (C) 2017 MIUI
京ICP备号 | 京公网安备34号 | 京ICP证110507号

我要回帖

更多关于 安卓x86 4.4 的文章

 

随机推荐