提交 f7d42de1 编写于 作者: G guoshuyu

Merge remote-tracking branch 'origin/master'

package com.danikula.videocache;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import java.io.File;
import static android.os.Environment.MEDIA_MOUNTED;
......@@ -48,14 +47,19 @@ final class StorageUtils {
private static File getCacheDirectory(Context context, boolean preferExternal) {
File appCacheDir = null;
String externalStorageState;
try {
externalStorageState = Environment.getExternalStorageState();
} catch (NullPointerException e) { // (sh)it happens
externalStorageState = "";
}
if (preferExternal && MEDIA_MOUNTED.equals(externalStorageState)) {
appCacheDir = getExternalCacheDir(context);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
appCacheDir = getExternalCacheDir(context);
}
}
if (appCacheDir == null) {
appCacheDir = context.getCacheDir();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册