Q: Cropping image and then saving it in gallery I am using the following code to crop an image using the android crop intent.
             Intent cropIntent = new Intent("com.android.camera.action.CROP", null)
         .setDataAndType(picUri,"image/*")
         .putExtra("crop", "true")
         .putExtra("aspectX", 1)
         .putExtra("aspectY", 1)
         .putExtra("outputX", 128)
         .putExtra("outputY", 128)
         .putExtra("scale", true)
         .putExtra("return-data", false)
         .putExtra("scaleUpIfNeeded", true)
         .putExtra(MediaStore.EXTRA_OUTPUT, picUri)
         .putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
         startActivityForResult(cropIntent, PIC_CROP);

Then I get the cropped picture from this code and I want to save it in a separate folder(created by my app) in the gallery. 
Here's the code to save the image :
    public static String SaveImage(Bitmap finalBitmap)
{
    String root = Environment.getExternalStorageDirectory().toString();
    File myDir = new File(root + "/Shopic Snaps");

    if(!myDir.exists())
        myDir.mkdirs();

    Random generator = new Random();
    int n = 10000;
    n = generator.nextInt(n);
    String fname = "Image_"+ n+ GenerateRandomName() +".jpg";
    File file = new File (myDir, fname);

    if (file.exists ()) 
        file.delete ();

    try
    {
           FileOutputStream out = new FileOutputStream(file);
           finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
           out.flush();
           out.close();
    }
    catch (Exception e)
    {
           e.printStackTrace();
    }

    return root + "/App Snaps/"+fname;
}

Now this function should save the picture in the gallery and return me the path to the picture.The code runs normally with no errors.
But after performing the tasks when I check the gallery, it is empty. I have no idea why it is not saving the picture in the gallery.
Edit:
I tested the app in another mobile and the pictures are saving fine in them and being showed. So I guess this is a problem in my mobile but I don't know what is causing the problem.

A: // Initialize intent
Intent intent = new Intent("com.android.camera.action.CROP");
// set data type to be sent
intent.setType("image/*");

// get croppers available in the phone
List<ResolveInfo> list = getPackageManager().queryIntentActivities( intent, 0 );
int size = list.size();
// handle the case if there's no cropper in the phone
if (size == 0) {
    Toast.makeText(this, "Can not find image crop app", Toast.LENGTH_SHORT).show();
    return;
} else {

// now this is the case if cropper exists
// initialize the Uri for the captures or gallery image

    Uri imageUri = Uri.fromFile(new File(mCurrentPhotoPath));

    // Send the Uri path to the cropper intent
    intent.setData(imageUri); 
    intent.putExtra("outputX", 200);
    intent.putExtra("outputY", 200);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);         
    intent.putExtra("scale", true);
    // Here's my attempt to ask the intent to save output data as file
    File f = null;
    // Here I initialize empty file 
    try{
            // This returns the file created
        f = setUpCroppedFile();
        mCurrentThumbPath = f.getAbsolutePath();            
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));            
        intent.putExtra("output", Uri.fromFile(f));         
    }
    catch(IOException e){
        e.printStackTrace();
    }

    intent.putExtra("return-data", false);
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------

    // If there's only 1 Cropper in the phone (e.g. Gallery )
    if (size == 1) {
            // get the cropper intent found
            Intent i        = new Intent(intent);
            ResolveInfo res = list.get(0);

            i.setComponent( new ComponentName(res.activityInfo.packageName, res.activityInfo.name));

            startActivityForResult(i, CROPPED_PHOTO);
    }


A: check the file explorer , whether the file gets stored in the device.. if the file stored but not displayed in the gallery..? try this
Note: Follow the steps for both Internal and external SD Card
Go to File manager -> Android -> Data -> com.android.gallery3d.
Delete the folder (com.android.gallery3d) in both internal and external SD card.
Go to Settings -> Apps / Application manager -> search for Gallery -> open Gallery and tap on Clear Data .
Switch off your phone and wait for few minutes (say 2-3 min) and then switch on and wait for few minutes.
That's it now. All the images and videos would be showing under Gallery.
