Reputation: 1153
In the fragment class inside Asynctask I am getting a constructor undefined error.
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;
}
Anyone can help me with this what parameter I have to pass it.Thank you.
Upvotes: 0
Views: 116
Reputation: 112
File does not contain a constructor that takes a File object.
Replace the one line of code with this:
File file = Constants.getAudioStoragePath();
Note that you will also need to update you Constants class to contain a getAudioStoragePath() method that takes no parameters.
The above will fix your "undefined constructor" error. Your next problem will most likely be when you create a FileOutputStream. Your file that you get from constants is actually a directory, if I read this code correctly. You need to create a File inside the Directory that you write to.
Upvotes: 1
Reputation: 15774
Adding to the answer of Johan Prins, pass appropriate parameters like:
File file = Constants.getAudioStoragePath(getActivity(), "myFolder");
Upvotes: 1