daniel-s
6/9/2014 - 8:32 AM

Write to file in Java/Android

Write to file in Java/Android

// Save to storage/folder/
File fileDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/folder/");
fileDir.mkdirs();

String name = "file.txt";
File mFile = new File(fileDir, name);

BufferedWriter writer = null;
try
{
  writer = new BufferedWriter(new FileWriter(mFile, true));
  writer.write("something");
}
catch (IOException e) 
{
  
}
finally
{
  if (writer != null) writer.close();
}