Skip to content

Instantly share code, notes, and snippets.

@jojojames
Created August 8, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jojojames/fe056d65ea8de7ae3df7 to your computer and use it in GitHub Desktop.
Save jojojames/fe056d65ea8de7ae3df7 to your computer and use it in GitHub Desktop.
File root = Environment.getExternalStorageDirectory();
File dir = new File (root.getAbsolutePath() + "/FlightData");
File file = new File(dir, "FlightData.csv");
file.delete();
dir.delete();
File dir = new File (root.getAbsolutePath() + "/FlightData");
if (!dir.exists())
dir.mkdirs();
file = new File(dir, "FlightData.csv");
FileOutputStream out = null;
try {
out = new FileOutputStream(file, true);
out.write(dataString.getBytes());
}
catch (Exception e) {
if ( Log.isLoggable(tag, Log.WARN))
Log.w(tag, "Exception trying to save flight data " + dataString, e);
} finally {
try {
if (out !=null) {
out.flush();
out.close();
}
} catch (IOException e) {
Log.w(tag, "Exception trying to close flight data", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment