Android Development: Save pictures on sd card

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.