The following code will help you write text to a file and save it in the root directory
First get the text from your text box
String text = myTextView.getText().toString();
Then write the following instructions for writing to a text file
File logFile = new File(Environment.getExternalStorageDirectory().toString(), "myFile.txt"); if(!logFile.exists()) { logFile.createNewFile(); } BufferedWriter output = new BufferedWriter(new FileWriter(logFile)); output.write(text); output.close();
And your file will be saved in the root directory
Remember to add WRITE_EXTERNAL_STORAGE to your manifest
source share