What is the correct way to put the address inside Path?

1

Because I can not locate my .txt file. Here is the code:

public void criatxt() {

    String texto = "XXX";

    try {
        String filePath = this.getFilesDir().getPath().toString()
                + "/meuarquivo.txt";
        File f = new File(filePath);
        PrintWriter arq = new PrintWriter(f);
        System.out.println("Salvou");
        arq.print(texto);
        arq.close();
    } catch (Exception er) {
        er.printStackTrace();
        System.out.println("Salvou: " + er.getStackTrace());
    }
}

Thank you in advance!

    
asked by anonymous 25.08.2015 / 17:20

1 answer

1

Use

File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

To get the path of the android download folder, it will be easy for you to find your saved files.

    
14.09.2015 / 15:53