1 byte[] bytes = DECODEIMAGSTR (imgstring);//using Base64 to decode a picture2 if(Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {//Check the status of the SD card3String pathdir= environment.getexternalstoragedirectory () + constantsforfile.tmp_file_directory;//set File storage directory4String Picname =NewDate (). GetTime () + ". jpg";5File Dirfile =NewFile (pathdir);6 if(!dirfile.exists ()) dirfile.mkdirs ();//If no directory is created, Mkdirs guarantees that the parent directory is created if there is no parent directory7File Picfile =NewFile (Pathdir,picname);//Create a picture file8FileOutputStream FileOutputStream =NewFileOutputStream (Picfile);//using the file output stream9Fileoutputstream.write (bytes);//Output FileTen Fileoutputstream.flush (); One fileoutputstream.close (); A returnPicfile.getpath ();//Return picture path -}
Android Development: Save pictures on sd card