java - file not found exception android fileoutput stream -
i trying download xml url. getting java.io filenotfound sdcard.cellofest.xml permission denied
. lastly line generating error. have checked google , found lot of fixes, none solved problem.
i have write external storage permission in androidmanifest.
url url = new url("http://test.com/itsp/events/cellofest.xml"); // create new connection httpurlconnection urlconnection = (httpurlconnection) url.openconnection(); // set things on connection... urlconnection.setrequestmethod("get"); urlconnection.setdooutput(true); // , connect! urlconnection.connect(); // set path want save file. // in case, save on root directory of // sd card "\" log.d("xml download," , "just before downloading"); file sdcardroot = environment.getexternalstoragedirectory(); // create new file, specifying path, , filename, // chich want save file as. log.d("xml download" , "sd card root found"); file file = new file(sdcardroot,"cellofest.xml"); log.d("xml download" ,"fest.xml created."); //this used write downloaded info file created fileoutputstream fileoutput = new fileoutputstream(file);
you have create file before can utilize it. quick prepare follows.
// create new file, specifying path, , filename, // chich want save file as. log.d("xml download" , "sd card root found"); // file file = new file(sdcardroot,"cellofest.xml"); file file = file.createtempfile("cellofest", "xml", sdcardroot); log.d("xml download" ,"fest.xml created.");
this instantiates and creates file variable.
java android file
No comments:
Post a Comment