Android get image from internal/external storage -


i try show created png file in imageview. when start program , click showcreatedpng button, there white blank page on emulator's screen.

and logcat says : (maybe logcat shows errors because of emulator. emulator has 200 mb sd-card but, can not find created png in computer. when start program phone, png saved in gt-i9100\phone folder. guess folder internal folder. anyway, can not see created png file. please help.)

05-21 21:53:39.764: e/bitmapfactory(1335): unable decode stream: java.io.filenotfoundexception: /mnt/sdcard/*.png: open failed: enoent (no such file or directory) 

these codes used.

for saving :

private void saveimagetoexternalstorage(bitmap bitmap) {     string qrpath = environment.getexternalstoragedirectory().getabsolutepath() + "/";     try     {        file dir = new file(qrpath);        if (!dir.exists()) {           dir.mkdirs();        }        outputstream fout = null;        file file = new file(qrpath, "qrcode.png");        if(file.exists()){           file.delete();           file.createnewfile();           fout = new fileoutputstream(file);           bitmap.compress(bitmap.compressformat.png, 100, fout);           fout.flush();           fout.close();        }     }     catch (exception e) {       log.e("savetoexternalstorage()", e.getmessage());     } } 

and codes png file :

 string qrpath = environment.getexternalstoragedirectory().getabsolutepath() + "/*.png";  bitmapfactory.options options = new bitmapfactory.options();  options.inpreferredconfig = bitmap.config.argb_8888;  bitmap mustopen = bitmapfactory.decodefile(qrpath, options);   setcontentview(r.layout.qr_image);  imageview imageview = (imageview) findviewbyid(r.id.qr_image);  imageview.setimagebitmap(mustopen); 

thanks help.

you trying open file called *.png. should qrcode.png, code

environment.getexternalstoragedirectory().getabsolutepath() + "/qrcode.png"; 

Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -