I have been having problems with writing files on Android, I need to fill out a form and then store it in a PDF or txt file, for the moment I am trying it in txt but I can not write more than one line in it, due to that when trying to write on it and put line breaks at the end of each the content that is after the line break does not appear.
This is my writing code:
public void escribirDatos(){
try {
OutputStreamWriter fout = new OutputStreamWriter(openFileOutput(textEdit.getText().toString(), Context.MODE_APPEND));
fout.write("Fecha: 29/8/2017 Hora: 22:00" + '\n' + "Lugar y área: \t\t Levantamiento realizado por:");
fout.close();
Log.e("Creación","Archivo creado correctamente");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Reading:
public void leerDatos(){
try {
BufferedReader finLinea = new BufferedReader(new InputStreamReader(openFileInput(textEdit.getText().toString())));
String texto = finLinea.readLine();
textView.setText(texto);
finLinea.close();
}catch (Exception ex)
{
Log.e("Ficheros","Error al leer archivo");
}
}
I hope you can help me and thank you very much for your attention.