Search code examples
androidandroid-gallery

How can I notify the gallery of a new image in android?


I have an android app that allows you to open an image on your phone using an intent to the Gallery. You make modifications to that image and the app saves it with a new name in the same folder the original was in. Since the gallery can't constantly be looking for new images is there any way to notify the gallery of a new image from my android app so it shows up next time the user opens the gallery?


Solution

  • use the MediaScannerConnection -

    MediaScannerConnection.scanFile(context,
        new String[] { imagePath }, null,
        new MediaScannerConnection.OnScanCompletedListener() {                      
            @Override
            public void onScanCompleted(String path, Uri uri) {
                //....                              
            }
        });