Question: Android Studio - Java The following two questions assume that you have an application that has a user interface that shows a button, and EditText
Android Studio - Java
The following two questions assume that you have an application that has a user interface that shows a button, and EditText field, and another button to the user. The first button has an id of buttonSave and shows SAVE on the face of the button. The EditText has an id of editText and is initially empty. The second button has an id of buttonRestore and has RESTORE on the face of the button. Assuming that you have those visually components, questions 1 and 2 ask you to write the event handlers for the save and restore buttons so that when the SAVE button is clicked then whatever text is in the EditText field is saved to a file "text.dat". When the RESTORE button is pressed then whatever text currently resides in "text.dat" is pulled into the program and displayed on in the EditText field.
Question 1)
Write any missing code to the onClickSave method so that whatever text is in the EditText field is saved to the file "text.dat" (copy and paste this code as the start of your answer):
public void onClickSave(View view) { try { } catch (Exception e) { } } Question 2)
Write any missing code to the onClickRestore method so that whatever text is the file "text.dat" is read from the file and stored inot the EditText field. Assume the text is just one sentence. Have the EditText set to "NO TEXT AVAILABLE" if there is no "text.dat" file. Copy and paste this code as the start of your answer:
public void onClickRestore(View view) { try { } catch (Exception e) { } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
