Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void createTextFile(String fileName) {
- try {
- File notesDirectory = new File(Environment.getExternalStorageDirectory(), "Text Files");
- if (!notesDirectory.exists()) {
- notesDirectory.mkdirs();
- }
- File textFile = new File(notesDirectory, fileName);
- FileWriter writer = new FileWriter(textFile);
- writer.append("Sample Content");
- writer.flush();
- writer.close();
- Toast.makeText(this, "File Created at "+textFile.getAbsolutePath(), Toast.LENGTH_SHORT).show();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement