0
In my registration app I have the name and phone information. After entering the information and clicking register, a text file is created with the registered information.
But I would like the created text file to be named with the name field information.
Example:
Name: Joao
Telephone: 123
Text file created: Joao.txt
Currently, I create and name the file with the following command:
FileOutputStream ArqTexto = new FileOutputStream(Environment.getExternalStorageDirectory() + "/Clientes.txt");
I have already stored the value inserted in the name field in a variable, but I don’t know how to make the correct syntax.
I tried so:
FileOutputStream ArqTexto = new FileOutputStream(Environment.getExternalStorageDirectory() + VariavelNome +".txt");
But it didn’t work.
We missed a
/
between the directory and itsVariavelNome
.– Paulo Rodrigues
Great @Paulorodrigues thank you so much! That’s right!
– Negruts
It is interesting also you remove possible special characters when give names to these files, because in some cases your application can give a force close.
– Paulo Rodrigues