File tree 1 file changed +7
-2
lines changed
library/src/com/nostra13/universalimageloader/utils
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,13 @@ public static File getCacheDirectory(Context context) {
65
65
*/
66
66
public static File getCacheDirectory (Context context , boolean preferExternal ) {
67
67
File appCacheDir = null ;
68
- if (preferExternal && MEDIA_MOUNTED
69
- .equals (Environment .getExternalStorageState ()) && hasExternalStoragePermission (context )) {
68
+ String externalStorageState ;
69
+ try {
70
+ externalStorageState = Environment .getExternalStorageState ();
71
+ } catch (NullPointerException e ) { // (sh)it happens (Issue #660)
72
+ externalStorageState = "" ;
73
+ }
74
+ if (preferExternal && MEDIA_MOUNTED .equals (externalStorageState ) && hasExternalStoragePermission (context )) {
70
75
appCacheDir = getExternalCacheDir (context );
71
76
}
72
77
if (appCacheDir == null ) {
You can’t perform that action at this time.
0 commit comments