Skip to content

Commit

Permalink
sometimes getExternalFilesDir returns null, and the app crashes in th…
Browse files Browse the repository at this point in the history
…is case
  • Loading branch information
poison committed Jun 4, 2018
1 parent a3cf145 commit 4c4c5ea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ static public Map<String, Object> getSystemfolders(ReactApplicationContext ctx)
state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
res.put("SDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath());
res.put("SDCardApplicationDir", ctx.getExternalFilesDir(null).getParentFile().getAbsolutePath());

File externalDirectory = ctx.getExternalFilesDir(null);
if (externalDirectory != null) {
res.put("SDCardApplicationDir", externalDirectory.getParentFile().getAbsolutePath());
}
}
res.put("MainBundleDir", ctx.getApplicationInfo().dataDir);
return res;
Expand Down

1 comment on commit 4c4c5ea

@chrusart
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fixed in 0.10.9 as well

Please sign in to comment.