How to name a text file with information from an EditText?

0

In my registration application I have the name and phone information. After entering the information and clicking on register, a text file is created with the information registered.

But I would like the created text file to be named with the name field information.

Example:

  

Name: Joao
Phone: 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 entered in the name field in a variable, but I do not know how to do the correct syntax.

I tried this way:

FileOutputStream ArqTexto = new FileOutputStream(Environment.getExternalStorageDirectory() + VariavelNome +".txt");

But it did not work.

    
asked by anonymous 24.04.2015 / 13:35

1 answer

0

The correct one is:

FileOutputStream ArqTexto = new FileOutputStream(Environment.getExternalStorageDirectory() +"/"+ VariavelNome +".txt");

Missed bar.

    
24.04.2015 / 14:10