Android How to use MediaScannerConnection scanFile

前端 未结 8 1671
醉梦人生
醉梦人生 2020-11-22 07:20

Im adding images to a folder on the SDCARD. Since the images and my folder is not immediately visible in the Gallery im trying to get the MediaScannerConnection to update an

8条回答
  •  死守一世寂寞
    2020-11-22 07:47

    File file = new File(absolutePath);
    Uri uri = Uri.fromFile(file);
    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
    sendBroadcast(intent);
    

提交回复
热议问题