Skip to content

Commit

Permalink
Fix NPE in BackupUtil.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 30, 2020
1 parent d40783f commit 0bf0eba
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ public static boolean hasBackupFiles(@NonNull Context context) {
if (Permissions.hasAll(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
try {
File directory = StorageUtil.getBackupDirectory();
return directory.exists() && directory.isDirectory() && directory.listFiles().length > 0;

if (directory.exists() && directory.isDirectory()) {
File[] files = directory.listFiles();
return files != null && files.length > 0;
} else {
return false;
}
} catch (NoExternalStorageException e) {
Log.w(TAG, "Failed to read storage!", e);
return false;
Expand Down

0 comments on commit 0bf0eba

Please sign in to comment.