Directory Download Android

Asked

Viewed 3,532 times

1

Hello, in my app I download a CSV file, but it never appears in Smartphone Downloads, I can only view it with the File Manager. And also when I try to pass the file to the computer, I can’t find the directory that was saved. The file path is this /Storage/Emulated/0/Download/16hrs.csv. How do I show the file on smartphone downloads and how do I get this file from the computer? obg

private File getStorageDir(String fileName) {
    return new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS), fileName);
}
File f = getStorageDir(fileName);
FileWriter mFileWriter = null;

mFileWriter = new FileWriter(filePath , true);
writer = new CSVWriter(mFileWriter,';',' ');

String[] dTitle = {"Academia","Data", "Turma","Aluno","Piscinas","Metros","Tempo"};

writer.writeNext(dTitle);
writer.close();
mFileWriter.close();

1 answer

2

To get the correct path from the android downloads folder use the following code:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.