如果设备不足5.0,我有这个代码可以精确检查下载文件的当前大小。
例如:我的下载文件是200MB,在下载时我检查文件路径和文件大小< 200MB。
但是从5.0开始它返回文件的整个大小,它总是返回200MB所以我无法将进度设置为进度条。请帮帮我。
filesize = Integer.parseInt(String.valueOf(file.length() / 1024));
答案 0 :(得分:0)
Because this is the mechanism of Android 5.0. So I decided to change the way to get the current downloading file size by this code:
currentSize=cursorCheckCurrentSize.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR));
It will return the bytes downloaded of the downloading file and I can play around with the result