Can't save compressed file to temporary storage Android -
i have code create temporary file save compressed image file before sending out server. image gets server , saved. problem file 0 kb , i'm sure compression isn't good. looks file isn't getting saved fileoutputstream
, after reading documentation , examples, i'm not seeing why not. also, bitmap has 8294400 bytes , saved file has length of 0. that's why think happens while being sent out on fileoutputstream
.
bitmapdrawable drawable = (bitmapdrawable) profileimage.getdrawable(); bitmap bmap = drawable.getbitmap(); string filename = "tempimage"; file file = null; try {; file = file.createtempfile(filename, null, getapplicationcontext().getcachedir()); } catch (ioexception e) { e.printstacktrace(); } fileoutputstream fout = null; try { fout = new fileoutputstream(file); } catch (filenotfoundexception e) { e.printstacktrace(); } try { fout = openfileoutput(filename, mode_private); bmap.compress(bitmap.compressformat.jpeg, 100, fout); fout.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }
Comments
Post a Comment