java - Saving image in Gallery -
i taking screenshot , saving in storage application name. it's not giving error , saving photo in storage, appears in gallery after restart phone.
my save method photo below:
public void savequoteimage(bitmap quoteimage){ date = new date(); android.text.format.dateformat.format("yyyy-mm-dd_hh:mm:ss", now); try { // image naming , path include sd card appending name choose file string dirpath=environment.getexternalstoragedirectory().tostring()+file.separator+"quotes_king"; file dirfile=new file(dirpath); if(!dirfile.exists())dirfile.mkdirs(); // string mpath = environment.getexternalstoragedirectory().tostring() + "/" + + ".jpg"; // create bitmap screen capture file imagefile = new file(dirfile.getpath()+file.separator+ + ".jpg"); fileoutputstream outputstream = new fileoutputstream(imagefile); int quality = 100; quoteimage.compress(bitmap.compressformat.jpeg, quality, outputstream); outputstream.flush(); outputstream.close(); } catch (throwable e) { // several error may come out file handling or oom e.printstacktrace(); } }
what missing in ?
thanks
you have tell @ mediascanner file exists.
something this:
public final void addmanually(file file) { try{ mediastore.images.media.insertimage(mcontext.getcontentresolver(), file.getabsolutepath(), file.getname(), null); mcontext.sendbroadcast(new intent( intent.action_media_scanner_scan_file, uri.fromfile(file)) ); } catch (filenotfoundexception e) { e.printstacktrace(); } }
Comments
Post a Comment