Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public void createTextFile(String fileName) {
  2. try {
  3. File notesDirectory = new File(Environment.getExternalStorageDirectory(), "Text Files");
  4. if (!notesDirectory.exists()) {
  5. notesDirectory.mkdirs();
  6. }
  7. File textFile = new File(notesDirectory, fileName);
  8. FileWriter writer = new FileWriter(textFile);
  9. writer.append("Sample Content");
  10. writer.flush();
  11. writer.close();
  12. Toast.makeText(this, "File Created at "+textFile.getAbsolutePath(), Toast.LENGTH_SHORT).show();
  13. } catch (IOException e) {
  14. e.printStackTrace();
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement