Last active
January 10, 2018 00:16
-
-
Save valterh4ck3r/64c1d5c764dabcbc1b520674c757652f to your computer and use it in GitHub Desktop.
Write in File Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void writeToFile(String data) { | |
try { | |
File root = new File(Environment.getExternalStorageDirectory(), "Debug"); | |
if (!root.exists()) { | |
root.mkdirs(); | |
} | |
File file = new File(root, "debug.txt"); | |
FileWriter writer = new FileWriter(file); | |
writer.append(data); | |
writer.flush(); | |
writer.close(); | |
Log.e("FILE" , "FILE CREATED"); | |
} | |
catch (IOException e) { | |
Log.e("Exception", "File write failed: " + e.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment