将文件路径更改为更常见的文件夹

时间:2017-10-05 17:03:09

标签: java android export-to-csv

我目前有一个简单的代码,我将CSV文件保存在一个文件夹中,根据我的android studio监视器,我成功将该文件保存在一个文件夹中,我无法访问哪个是" / storage /emulated/0/Download/myfolder/552.csv"

File path =new 
File(Environment.getExternalStoragePublicDirectory(Environment. + 
DIRECTORY_DOWNLOADS),"myfolder");

    System.out.println(path);
    if (!path.exists()){
        path.mkdir();
    }
    File mypath=new File(path,(editSesion.getText().toString()+".csv"));
    FileWriter mFile = new FileWriter(mypath,true);
    CSVWriter writer = new CSVWriter(new FileWriter(mypath));
    System.out.println(mypath);

有没有办法获得更常用的文件夹的路径?

2 个答案:

答案 0 :(得分:0)

/ storage / emulated / 0 / Download / 是手机存储空间的“下载”文件夹。

您期望的共同目录是多少?

答案 1 :(得分:0)

请添加 / (正斜杠),例如 myfolder /

File(Environment.getExternalStoragePublicDirectory(Environment. + 
DIRECTORY_DOWNLOADS),"myfolder");

改为

File(Environment.getExternalStoragePublicDirectory(Environment. + 
DIRECTORY_DOWNLOADS),"myfolder/");