Skip to content

Commit 6924759

Browse files
committed
fix(app, android): handle possible null external storage directory
Environment.getExternalStoragePublicDirectory can return null when external storage is unavailable; guard the pictures and movies directory constants instead of dereferencing getAbsolutePath directly.
1 parent eef34e7 commit 6924759

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/app/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ protected Map<String, Object> getTypedExportedConstants() {
160160
constants.put(KEY_DOCUMENT_DIRECTORY, context.getFilesDir().getAbsolutePath());
161161
}
162162

163+
File picturesDirectory =
164+
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
163165
constants.put(
164-
KEY_PICS_DIRECTORY,
165-
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
166-
.getAbsolutePath());
166+
KEY_PICS_DIRECTORY, picturesDirectory != null ? picturesDirectory.getAbsolutePath() : "");
167167

168+
File moviesDirectory =
169+
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
168170
constants.put(
169-
KEY_MOVIES_DIRECTORY,
170-
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
171-
.getAbsolutePath());
171+
KEY_MOVIES_DIRECTORY, moviesDirectory != null ? moviesDirectory.getAbsolutePath() : "");
172172

173173
File externalStorageDirectory = Environment.getExternalStorageDirectory();
174174
if (externalStorageDirectory != null) {

0 commit comments

Comments
 (0)