我正在尝试使用以下代码创建一个新文件,但是出现了 "java.io.IOException: open failed: ENOENT(没有这样的文件或目录)" 错误。
这是我的代码:希望你能帮助我。
final File f = new File(Environment.
getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS).getPath() + "/"
+ MainActivity.getContext().getPackageName()
+ "/wifip2pshared-" + System.currentTimeMillis()
+ ".jpg");
Log.d("WIFI","file created :"+f.getAbsolutePath());
File dirs = new File(f.getParent());
Log.d("WIFI","dir created :"+dirs.getAbsolutePath());
dirs.mkdirs();
f.createNewFile();
我已经在Android清单文件中声明了该权限。