+ // Create a string for the default file path.
+ String defaultFilePath;
+
+ // Get a handle for the context.
+ Context context = getContext();
+
+ // Remove the incorrect lint warning below that context might be null.
+ assert context != null;
+
+ // Set the default file path according to the storage permission state.
+ if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // The storage permission has been granted.
+ // Set the default file path to use the external public directory.
+ defaultFilePath = Environment.getExternalStorageDirectory() + "/" + getString(R.string.privacy_browser_logcat_txt);
+
+ // Hide the storage permission text view.
+ storagePermissionTextView.setVisibility(View.GONE);
+ } else { // The storage permission has not been granted.
+ // Set the default file path to use the external private directory.
+ defaultFilePath = context.getExternalFilesDir(null) + "/" + getString(R.string.privacy_browser_logcat_txt);
+ }
+
+ // Display the default file path.
+ fileNameEditText.setText(defaultFilePath);
+