android FileNotFoundException错误:创建文件失败 No such file or directory

在Android真机上测试时报错:java.io.FileNotFoundException: /storage/emulated/0/DownFile/。。。: open failed: ENOENT (No such file or directory)

报错:

java.io.FileNotFoundException: /storage/emulated/0/DownFile/。。。: open failed: ENOENT (No such file or directory)

路径:

 String savePAth = Environment.getExternalStorageDirectory() + "/DownFile/";

创建时一直失败。
需要把路径改为:

String savePAth = getExternalCacheDir()+"/DownFile/";

你可能感兴趣的:(错误)