title: Android: how to save image in my created folder with its actual size
body: <p>I want to save my photo in my created folder with its actual size. For this I tried lots of code but in all case photo saved in gallery with its actual size but when I saved this photo in my location then photo get compressed.
  After that I tried to copy photo from Gallery to my folder to get photo with its actual size. In this case photo is copping but not with its actual size. It again get compressed.
  For opening the camera:</p>
  
  <pre><code>    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  startActivityForResult(
              Intent.createChooser(cameraIntent, "Select Picture"),
              CAMERA_REQUEST);
  </code></pre>
  
  <p>after that in <strong>onActivityResult</strong> method :</p>
  
  <pre><code>try {
          if (requestCode == CAMERA_REQUEST) {
              Bitmap photo = (Bitmap) data.getExtras().get("data");
  
              if (photo != null) {
                  imageView.setImageBitmap(photo);
              }
  
              // Image name
  
              final ContentResolver cr = getContentResolver();
              final String[] p1 = new String[] {
                      MediaStore.Images.ImageColumns._ID,
                      MediaStore.Images.ImageColumns.DATE_TAKEN };
              Cursor c1 = cr.query(
                      MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null,
                      null, p1[1] + " DESC");
              if (c1.moveToFirst()) {
                  String uristringpic = "content://media/external/images/media/"
                          + c1.getInt(0);
                  Uri newuri = Uri.parse(uristringpic);
                  // Log.i("TAG", "newuri "+newuri);
                  String snapName = getRealPathFromURI(newuri);
  
                  Uri u = Uri.parse(snapName);
  
                  File f = new File("" + u);
                  String fileName = f.getName();
  
                  editTextPhoto.setText(fileName);
                  checkSelectedItem = true;
  
                  ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  photo.compress(CompressFormat.PNG, 0 /* ignored for PNG */,
                          bos);
                  byte[] bitmapdata = bos.toByteArray();
  
                  // Storing Image in new folder
  
  
  //  StoreByteImage(mContext, bitmapdata, 100, fileName);
  
  
                  copyImageFromGallery(newuri);
  
  
  
  
  
  
                  // To appear images in created folder of Gallery dynamically
                  // as soon as they
                  // are captured.
                  sendBroadcast(new Intent(
                          Intent.ACTION_MEDIA_MOUNTED,
                          Uri.parse("file://"
                                  + Environment.getExternalStorageDirectory())));
  
                  // Delete the image from the Gallery
  
                  getContentResolver().delete(newuri, null, null); // for delete
  
              }
              c1.close();
  
          }
      } catch (NullPointerException e) {
          System.out.println("Error in creating Image." + e);
  
      } catch (Exception e) {
          System.out.println("Error in creating Image." + e);
      }
  </code></pre>
  
  <p>now I copying my Image form Gallery to my folder:</p>
  
  <pre><code>protected void copyImageFromGallery(Uri uri){
  
      try {
          File sd = Environment.getExternalStorageDirectory();
          File data = Environment.getDataDirectory();
          if (sd.canWrite()) {
              String sourceImagePath= uri.toString();
  
  
              File sdImageMainDirectory = new File(
                      Environment.getExternalStorageDirectory() + "/pix/images");
                  if (!sdImageMainDirectory.exists()) {
                      sdImageMainDirectory.mkdirs();
                  }
  
  
  
              String destinationImagePath= Environment.getExternalStorageDirectory() + "/pix/images";
              File source= new File(data, souceImagePath);
              File destination= new File(sd, destinationImagePath);
              if (source.exists()) {
                  FileChannel src = new FileInputStream(source).getChannel();
                  FileChannel dst = new FileOutputStream(destination).getChannel();
                  dst.transferFrom(src, 100, src.size());
                  src.close();
                  dst.close();
              }
      }} catch (Exception e) {}
  
  
      }
  </code></pre>
  
  <p>here photo is copying in my folder but till it compressed.</p>