Android file is not creating -


in android project i'm saving image file device. in there use following code creating file.

file folder = new file(getfilesdir());         if (!folder.exists()) {             folder.mkdir();         } file imagefile = new file(folder, filename); try   {   fileoutputstream fos = new fileoutputstream(imagefile);   bitmap.compress(bitmap.compressformat.png, 100, fos);   fos.close();   }   catch (exception e)   {     e.printstacktrace();   } 

but gives me file not found exception when creating fileoutputstream

fileoutputstream fos = new fileoutputstream(imagefile); 

so file seems not creating. how can fix this.

i think folder wasn't created. if folder has path one: /folder1/folder2. try create folder1 first create folder2 ?. after that, run code again.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -