在Asynctask中的片段类中,我得到了一个构造函数未定义的错误。
protected String doInBackground(String... f_url) {
..............
.............
File file = new File(Constants.getAudioStoragePath()); --->Undefined constructor
//this will be used to write the downloaded data into the file we created
FileOutputStream fileOutput = new FileOutputStream(file);
}Constants.java:
public static File getAudioStoragePath(Context context, String folderName) throws IOException {
File baseFolder = getFolder(context, "audio");
File folder = new File(baseFolder, folderName);
if (!folder.exists()) folder.mkdirs();
return folder;
}任何人都可以帮我处理这个参数,我必须传递给it.Thank你。
发布于 2015-02-21 07:53:30
添加到answer of Johan Prins中,传递适当的参数,如:
File file = Constants.getAudioStoragePath(getActivity(), "myFolder");
发布于 2015-02-21 07:48:58
文件不包含接受File对象的构造函数。
将一行代码替换为:
File file = Constants.getAudioStoragePath();请注意,还需要更新常量类,以包含不接受参数的getAudioStoragePath()方法。
以上将修复您的“未定义构造函数”错误。下一个问题很可能是当您创建一个FileOutputStream时。如果我正确阅读这段代码,您从常量中获得的文件实际上是一个目录。您需要在您写入的目录中创建一个文件。
https://stackoverflow.com/questions/28643432
复制相似问题