I have following code to save image from url to Download
folder
var filename = url.replace(/^.*[\\\/]/, '');
var filePath = cordova.file.externalRootDirectory + 'Download/' + filename;
$cordovaFile.downloadFile(url, filePath, true, {})
.then(function(result) {
// Success!
$cordovaToast.showShortCenter('This picture has been saved!');
}, function(err) {
$ionicPopup.alert({ title: 'Error!', template: angular.toJson(err) });
});
It saves the image successfully. I can explore the file in the SD card. But it is not visible in Gallery app. When i search for it, i found that we should run some media scanner on that file.
How do i run media scanner? is there any api?
Finally i found an answer. Run the media Scanner inside file download success callback.