修复部分bug
This commit is contained in:
@ -37,7 +37,11 @@ public class FileUtils {
|
||||
File file = new File(dir + File.separator + TEST_FILE_NAME);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
if (!file.createNewFile()) {
|
||||
// cannot create file
|
||||
Utils.log("cannot create file");
|
||||
dir = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//cannot create file
|
||||
@ -124,7 +128,7 @@ public class FileUtils {
|
||||
return availableBlocks * blockSize / 1024f / 1024f;
|
||||
}
|
||||
|
||||
public static String isCanDownload(String size) {
|
||||
public static String isCanDownload(Context context, String size) {
|
||||
String msg = null;
|
||||
String packageSizeStr = "";
|
||||
for (int i = 0; i < size.length(); i++) {
|
||||
@ -136,8 +140,7 @@ public class FileUtils {
|
||||
if (packageSizeStr.length() != 0) {
|
||||
packageSize = Float.valueOf(packageSizeStr);
|
||||
}
|
||||
float freeSpace = getFreeSpaceByPath(Environment
|
||||
.getExternalStorageDirectory().getAbsolutePath());
|
||||
float freeSpace = getFreeSpaceByPath(getDownloadDir(context));
|
||||
if (freeSpace < packageSize) {
|
||||
msg = "手机存储空间不足,无法进行下载!";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user