Use Activity or Application context to call openFileOutput
method from DownloadBook
class as:
FileOutputStream fos =
getApplicationContext().openFileOutput( title+".html", Context.MODE_PRIVATE);
If DownloadBook
is separate java class then use class constructor for getting Activity context for calling openFileOutput
method as:
public class DownloadBook extends AsyncTask<String, Void, String> {
private Context context;
public DownloadBook(Context context){
this.context=context;
}
}
Now use context
for calling openFileOutput
method :
FileOutputStream fos =
context.openFileOutput( title+".html", Context.MODE_PRIVATE);
From Activity pass context to DownloadBook class constructor :
DownloadBook obj_Downloadbook=new DownloadBook(getApplicationContext());