title: How to Save images in an specific folder android
body: <p>I'm a newbie about android programming </p>
  
  <p>I would like to create folder for store image from my app when user click save </p>
  
  <p>I can save image to my device </p>
  
  <p>but I have no idea to create specific folder ,How to create folder??</p>
  
  <p>thanks for your help!</p>
  
  <p>and sorry my english is not good.</p>
  
  <p>My code</p>
  
  <pre><code>CapturePhotoUtils.insertImage(context.getContentResolver(), myBitmap, title ,des);
  </code></pre>
  
  <p>and  CapturePhotoUtils.java</p>
  
  <pre><code>public class CapturePhotoUtils {
  
  
      public static final String insertImage(ContentResolver cr,
                                             Bitmap source,
                                             String title,
                                             String description) {
  
          ContentValues values = new ContentValues();
          values.put(Images.Media.TITLE, title);
          values.put(Images.Media.DISPLAY_NAME, title);
          values.put(Images.Media.DESCRIPTION, description);
          values.put(Images.Media.MIME_TYPE, "image/jpeg");
          // Add the date meta data to ensure the image is added at the front of the gallery
          values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
          values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
  
          Uri url = null;
          String stringUrl = null;    /* value to be returned */
  
          try {
              url = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  
              if (source != null) {
                  OutputStream imageOut = cr.openOutputStream(url);
                  try {
                      source.compress(Bitmap.CompressFormat.JPEG, 50, imageOut);
                  } finally {
                      imageOut.close();
                  }
  
                  long id = ContentUris.parseId(url);
                  // Wait until MINI_KIND thumbnail is generated.
                  Bitmap miniThumb = Images.Thumbnails.getThumbnail(cr, id, Images.Thumbnails.MINI_KIND, null);
                  // This is for backward compatibility.
                  storeThumbnail(cr, miniThumb, id, 50F, 50F,Images.Thumbnails.MICRO_KIND);
              } else {
                  cr.delete(url, null, null);
                  url = null;
              }
          } catch (Exception e) {
              if (url != null) {
                  cr.delete(url, null, null);
                  url = null;
              }
          }
  
          if (url != null) {
              stringUrl = url.toString();
          }
  
          return stringUrl;
      }
  
      private static final Bitmap storeThumbnail(
              ContentResolver cr,
              Bitmap source,
              long id,
              float width,
              float height,
              int kind) {
  
          // create the matrix to scale it
          Matrix matrix = new Matrix();
  
          float scaleX = width / source.getWidth();
          float scaleY = height / source.getHeight();
  
          matrix.setScale(scaleX, scaleY);
  
          Bitmap thumb = Bitmap.createBitmap(source, 0, 0,
                  source.getWidth(),
                  source.getHeight(), matrix,
                  true
          );
  
          ContentValues values = new ContentValues(4);
          values.put(Images.Thumbnails.KIND,kind);
          values.put(Images.Thumbnails.IMAGE_ID,(int)id);
          values.put(Images.Thumbnails.HEIGHT,thumb.getHeight());
          values.put(Images.Thumbnails.WIDTH,thumb.getWidth());
  
          Uri url = cr.insert(Images.Thumbnails.EXTERNAL_CONTENT_URI, values);
  
          try {
              OutputStream thumbOut = cr.openOutputStream(url);
              thumb.compress(Bitmap.CompressFormat.JPEG, 100, thumbOut);
              thumbOut.close();
              return thumb;
          } catch (FileNotFoundException ex) {
              return null;
          } catch (IOException ex) {
              return null;
          }
      }
  </code></pre>