Created
April 21, 2020 22:00
-
-
Save alfredoem/3a985566bd0bd37d3aee3ab2e3786d96 to your computer and use it in GitHub Desktop.
This file contains 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
try { | |
File nuevaCarpeta = new File(Environment.getExternalStorageDirectory(), "NombreNuevaCarpeta"); | |
if (!nuevaCarpeta.exists()) { | |
nuevaCarpeta.mkdir(); | |
} | |
try { | |
File file = new File(nuevaCarpeta, "ArchivoDePrueba" + ".txt"); | |
file.createNewFile(); | |
FileOutputStream stream = new FileOutputStream(file); | |
try { | |
stream.write(new Gson().toJson("objeto o string sin Gson")).getBytes()); | |
} finally { | |
stream.close(); | |
} | |
} catch (Exception ex) { | |
Log.e("Error", "ex: " + ex); | |
} | |
} catch (Exception e) { | |
Log.e("Error", "e: " + e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment