Question: Can you do this java question using my previous questions 156 Chapter 4 String Land Here is the complete implementation- public void onSave(View v) DOING
156 Chapter 4 String Land Here is the complete implementation- public void onSave(View v) DOING try given a String name CCEditText) findViewByldcR.id.file)).getTexto File dir-this.getFilesDirO: File file new File(dir, name); FileWriter fw new FileWriter(file) fw.writeCCCEditText) findVi ewByIdCR.id.data)).getText fw.closeO; Toast.makeText Cthis, "Note Saved.", Toast.LENGTHLLONG); Cint close (CEditTe catch CException e) Toast.makeText(this, e.getHessageO, Toast. LENGTHLLONG This ha For the onLoad method, we need to examine the FileReader API more FileReader Constructor public FileReader (File name) Construct an instance that can read from the given file. Throws an exception if the instance cannot be created FileReader Methods public int read () Reads one character from the file and return its code or -1 if there are no more characters in the file. the given string to the file. Throws an exception if the operation cannot be completed be Co public void close () Disconnects the code from the file. Throws an exception if the operation cannot be completed. The method's body is similar to onSave except we need to read the file one character at i time and concatenate these characters into a string. This requires a loop that keeps seadirg until -1 is returned as shown below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
