Android (SpreadTurm)无T卡下载文件导致无法释放手机内存
2012-11-15 09:07
966 查看
SpreadTurm在无T卡情况下使用/data/internal_memory路径存储下载文件,在删除文件进行路径匹配时未包含此路径
增加此路径前缀匹配过程.
详细路径:packages\providers\DownloadProvider\ui\src\com\android\providers\downloads\ui\DownloadList.java
红色文字为增加匹配的代码
private void deleteDownload(long downloadId) {
if (moveToDownload(downloadId)) {
int status = mDateSortedCursor.getInt(mStatusColumnId);
boolean isComplete = status == DownloadManager.STATUS_SUCCESSFUL
|| status == DownloadManager.STATUS_FAILED;
String localUri = mDateSortedCursor.getString(mLocalUriColumnId);
if (isComplete && localUri != null) {
String path = Uri.parse(localUri).getPath();
if (path.startsWith(Environment.getExternalStorageDirectory().getPath())
|| path.startsWith(Environment.getDataDirectory().getPath())) {
String mediaProviderUri = mDateSortedCursor.getString(mMediaProviderUriId);
if (TextUtils.isEmpty(mediaProviderUri)) {
// downloads database doesn't have the mediaprovider_uri. It means
// this download occurred before mediaprovider_uri column existed
// in downloads table. Since MediaProvider needs the mediaprovider_uri to
// delete this download, just set the 'deleted' flag to 1 on this row
// in the database. DownloadService, upon seeing this flag set to 1, will
// re-scan the file and get the MediaProviderUri and then delete the file
mDownloadManager.markRowDeleted(downloadId);
return;
} else {
getContentResolver().delete(Uri.parse(mediaProviderUri), null, null);
// sometimes mediaprovider doesn't delete file from sdcard after deleting it
// from its db. delete it now
try {
File file = new File(path);
file.delete();
} catch (Exception e) {
Log.w(LOG_TAG, "file: '" + path + "' couldn't be deleted", e);
}
}
}
}
}
mDownloadManager.remove(downloadId);
}
增加此路径前缀匹配过程.
详细路径:packages\providers\DownloadProvider\ui\src\com\android\providers\downloads\ui\DownloadList.java
红色文字为增加匹配的代码
private void deleteDownload(long downloadId) {
if (moveToDownload(downloadId)) {
int status = mDateSortedCursor.getInt(mStatusColumnId);
boolean isComplete = status == DownloadManager.STATUS_SUCCESSFUL
|| status == DownloadManager.STATUS_FAILED;
String localUri = mDateSortedCursor.getString(mLocalUriColumnId);
if (isComplete && localUri != null) {
String path = Uri.parse(localUri).getPath();
if (path.startsWith(Environment.getExternalStorageDirectory().getPath())
|| path.startsWith(Environment.getDataDirectory().getPath())) {
String mediaProviderUri = mDateSortedCursor.getString(mMediaProviderUriId);
if (TextUtils.isEmpty(mediaProviderUri)) {
// downloads database doesn't have the mediaprovider_uri. It means
// this download occurred before mediaprovider_uri column existed
// in downloads table. Since MediaProvider needs the mediaprovider_uri to
// delete this download, just set the 'deleted' flag to 1 on this row
// in the database. DownloadService, upon seeing this flag set to 1, will
// re-scan the file and get the MediaProviderUri and then delete the file
mDownloadManager.markRowDeleted(downloadId);
return;
} else {
getContentResolver().delete(Uri.parse(mediaProviderUri), null, null);
// sometimes mediaprovider doesn't delete file from sdcard after deleting it
// from its db. delete it now
try {
File file = new File(path);
file.delete();
} catch (Exception e) {
Log.w(LOG_TAG, "file: '" + path + "' couldn't be deleted", e);
}
}
}
}
}
mDownloadManager.remove(downloadId);
}
相关文章推荐
- Android(SpreadTurm)无T卡下载文件导致无法释放手机内存
- Android Http下载文件到手机内存与SDCard
- android 默认浏览器 无法下载,此手机不支持此内容(自定义文件or APK文件看过了)
- android 中可能导致内存无法释放的原因(更新中)
- android手机(平板)下载文件后,在文件管理软件中可以看到,通过mtp模式连接电脑后,无法在电脑上看到
- Android手机ROOT之后更改字体文件导致无法启动的问题
- (android文件下载)下载链接中包含特殊字符--空格,中文等,导致无法识别处理方案
- Android开发实践经验谈:如何让各式手机浏览器可以直接下载apk安装文件且实现自动安装APP
- Android手机,使用adb上传文件,下载文件和安装文件
- Android DownloadManage 下载APK文件 点击广播栏 无法安装
- “/proc/meminfo”文件记录了android手机的一些内存信息
- WPF的BitmapImage的文件无法释放及内存泄露的问题
- [android] 保存文件到手机内存
- 【Android】DownloadManager 打开url下载的APK文件无法打开的问题 cannot open file
- android开发学习(二)——保存文件到手机内存和SD卡,文件访问权限,获取内存大小
- Android无法导入下载好的项目(和Eclipse中已经存在的项目命名一样导致冲突)解决办法
- 解决IE apk变成zip:Android 手机应用程序文件下载服务器 配置解决方法
- Android引用百度定位API第三方组件后导致其它.so文件无法正常加载的问题
- Android: 使用adb下载手机里的文件-七侠镇莫小贝-20170719
- android 手机内存创建文件存储相关