Commit 148ce3b7 authored by jianglx's avatar jianglx

优化下载路径

parent 24ed6d97
......@@ -24,7 +24,7 @@ public class DownloadAppUtils {
String packageName = context.getPackageName();
String rootPath = null;
rootPath = context.getExternalCacheDir().getPath() + File.separator + Environment.DIRECTORY_DOWNLOADS + File.separator ;
rootPath = getCachePath(context) + File.separator + Environment.DIRECTORY_DOWNLOADS + File.separator;
send(context, -1, serverVersionName);
File file = new File(rootPath);
if (!file.exists()) {
......@@ -75,4 +75,15 @@ public class DownloadAppUtils {
intent.putExtra("title", serverVersionName);
context.sendBroadcast(intent);
}
private static String getCachePath(Context context) {
String cachePath = null;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) {
cachePath = context.getExternalCacheDir().getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
return cachePath;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment