- // Enable the open button if a file name exists.
- openButton.setEnabled(!fileNameEditText.getText().toString().isEmpty());
+ // Get the current file name.
+ String fileNameString = fileNameEditText.getText().toString();
+
+ // Convert the file name string to a file.
+ File file = new File(fileNameString);
+
+ // Check to see if the file exists.
+ if (file.exists()) { // The file exists.
+ // Hide the notification that the file does not exist.
+ fileDoesNotExistTextView.setVisibility(View.GONE);
+
+ // Enable the open button.
+ openButton.setEnabled(true);
+ } else { // The file does not exist.
+ // Show the notification that the file does not exist.
+ fileDoesNotExistTextView.setVisibility(View.VISIBLE);
+
+ // Disable the open button.
+ openButton.setEnabled(false);
+ }