解决下载存储apk在data/data目录下导致的apk安装解析出错问题

This commit is contained in:
huangzhuanghua
2016-12-03 15:55:42 +08:00
parent 2f4688cb13
commit 1a9b23ca10
2 changed files with 19 additions and 2 deletions

View File

@ -46,7 +46,7 @@ public class FileUtils {
}
} catch (IOException e) {
e.printStackTrace();
//cannot create file
// cannot create file
Utils.log("cannot create file");
dir = null;
}
@ -55,6 +55,11 @@ public class FileUtils {
if (dir == null) {
String baseDir = context.getFilesDir().getAbsolutePath();
dir = checkDir(baseDir + File.separator + "gh-download");
try {
Runtime.getRuntime().exec("chmod 755 " + dir);
} catch (IOException e) {
e.printStackTrace();
}
}
return dir;
}
@ -81,7 +86,10 @@ public class FileUtils {
private static String checkDir(String dir) {
File directory = new File(dir);
if (!directory.exists() || !directory.isDirectory()) {
if (directory.exists() && !directory.isDirectory()) {
directory.delete();
}
if (!directory.exists()) {
directory.mkdirs();
}
return dir;