Skip to content

Commit

Permalink
fix(app, android): fixes possible crash on first launch (#4990)
Browse files Browse the repository at this point in the history
Fixes #4979
  • Loading branch information
JiboStore authored Mar 9, 2021
1 parent 038063e commit 06eebad
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ public Map<String, Object> getConstants() {
constants.put(KEY_TEMP_DIRECTORY, context.getCacheDir().getAbsolutePath());
constants.put(KEY_CACHE_DIRECTORY, context.getCacheDir().getAbsolutePath());


File externalDirectory = context.getExternalFilesDir(null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
constants.put(KEY_DOCUMENT_DIRECTORY, context.getExternalFilesDir(null).getAbsolutePath());
if ( externalDirectory != null ) {
constants.put(KEY_DOCUMENT_DIRECTORY, externalDirectory.getAbsolutePath());
}
} else {
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
}
Expand All @@ -179,7 +181,6 @@ public Map<String, Object> getConstants() {
constants.put(KEY_EXT_STORAGE_DIRECTORY, externalStorageDirectory.getAbsolutePath());
}

File externalDirectory = context.getExternalFilesDir(null);
if (externalDirectory != null) {
constants.put(KEY_EXTERNAL_DIRECTORY, externalDirectory.getAbsolutePath());
}
Expand Down

1 comment on commit 06eebad

@vercel
Copy link

@vercel vercel bot commented on 06eebad Mar 9, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.