Skip to content

Instantly share code, notes, and snippets.

@valterh4ck3r
Last active January 10, 2018 00:16
Show Gist options
  • Save valterh4ck3r/64c1d5c764dabcbc1b520674c757652f to your computer and use it in GitHub Desktop.
Save valterh4ck3r/64c1d5c764dabcbc1b520674c757652f to your computer and use it in GitHub Desktop.
Write in File Android
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