Search code examples
androidandroid-gallery

Refresh gallery on Android 7 downwards?


I can use MediaScannerConnection.scanFile() as of SDK 2.2+.

After taking an image and saving it on the sd card, how can I trigger scanning of images in SDKs lower than 2.2 (2.1 downwards)?


Solution

  • There are two MediaScannerConnection.scanFile(..) methods. Use the one available since API 1.

    // available since API 1
    scanFile (String path, String mimeType)  
    
    // available since API 8
    scanFile (Context context, String[] paths, String[] mimeTypes, MediaScannerConnection.OnScanCompletedListener callback)