java - Android App saving to SD Card -
i'm having trouble. i'm new java , android programming. i'm using template started , i'm stuck.
i have app pulls images tumblr feed , presents them on screen download button. works fine installs root of internal storage. how save folder in internal storage called "/pictures/tumblr"?
my code is:
public void onloadingcomplete(final string imageuri, view view, bitmap loadedimage) { spinner.setvisibility(view.gone); // close button click event btnsave.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string path = environment.getexternalstoragedirectory().tostring(); outputstream fout = null; file file = new file(path, "tumblr_"+images.get(position).getid()+".jpg"); try { fout = new fileoutputstream(file); bitmap bitmap = ((bitmapdrawable)imageview.getdrawable()).getbitmap(); bitmap.compress(bitmap.compressformat.jpeg, 100, fout); fout.flush(); fout.close(); mediastore.images.media.insertimage(getcontentresolver(),file.getabsolutepath(),file.getname(),file.getname()); string saved = getresources().getstring(r.string.saved); toast.maketext(getbasecontext(), saved + " " + file.tostring(), toast.length_long).show(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } });
i've tried changing the
file file = new file(path, "tumblr_"+images.get(position).getid()+".jpg");
to
file file = new file(path+"/pictures/tumblr", "tumblr_"+images.get(position).getid()+".jpg");
but know it's wrong.
can help?
Comments
Post a Comment