Skip to content

Commit 4c4c5ea

Browse files
committed
sometimes getExternalFilesDir returns null, and the app crashes in this case
1 parent a3cf145 commit 4c4c5ea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ static public Map<String, Object> getSystemfolders(ReactApplicationContext ctx)
213213
state = Environment.getExternalStorageState();
214214
if (state.equals(Environment.MEDIA_MOUNTED)) {
215215
res.put("SDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath());
216-
res.put("SDCardApplicationDir", ctx.getExternalFilesDir(null).getParentFile().getAbsolutePath());
216+
217+
File externalDirectory = ctx.getExternalFilesDir(null);
218+
if (externalDirectory != null) {
219+
res.put("SDCardApplicationDir", externalDirectory.getParentFile().getAbsolutePath());
220+
}
217221
}
218222
res.put("MainBundleDir", ctx.getApplicationInfo().dataDir);
219223
return res;

0 commit comments

Comments
 (0)