Once downloaded, images not display in android gallery? in ionic 3..stuck from last two month... please help

Below is my code which execute successfully and downloading image file successfully in given folder link but image not showing in mobile phone gallery, i have tried all things like after download image file i moving/copying from one location to another to refresh gallery but image not showing in gallery. please help how can I do in ionic 3.

// home.html page
  <button (click)="getPermission(adv.imgurl)" style="color: white;background: #ff7600;padding: 6px 27px;   border-radius: 6px;margin-left: 78px;">Download</button>
// home.ts page
getPermission(getlink) {
 this.src_link = getlink;
    // get permission from device to save    this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then(
        result =>//,
            err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE)
    );

    // get permission from device to save 
    this.androidPermissions.hasPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE)
        .then(status => {
            if (status.hasPermission) {
              this.downloadimage();             
            }
            else {
                this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE)
                    .then(status => {
                        if (status.hasPermission) {
                            this.downloadimage();                            
                        }
                    });
            }
        });
}



downloadimage(){
  const fileTransfer = this.transfer.create();
this.platform.ready().then(() => {

    this.filename = Math.floor(100000 + Math.random() * 900000);    

                  let url = encodeURI('http://myurl.com/myapp/'+this.src_link);
  fileTransfer.download(url, this.file2.externalRootDirectory +'/Foldername/Media/images/' + this.filename+".jpg",true).then((entry) => {
    alert('download complete: ' + JSON.stringify(entry.toURL()));
    //this.photoViewer.show(entry.toURL());

    this.moveToGallery(this.filename,entry.toURL());   
  }, (error) => {
    alert(JSON.stringify(error));
  });

      fileTransfer.onProgress((progress) => {
         var downloadProgress = Math.round((progress.loaded / progress.total) * 100) + '%';
              console.log('Downloading progress ...', downloadProgress);
              this.dprogress = downloadProgress;
          });

})
}

moveToGallery(filename, values){
    //this.path = "file:///storage/emulated/0/Foldername/Media/images";
   this.path = values.substr(0, values.lastIndexOf('/') + 1);
  this.newPath = "file:///storage/emulated/0/Foldername2";

  this.file2.moveFile(this.path, filename+'.jpg', this.newPath, filename+'.jpg').then(success => {
    alert('success.'+JSON.stringify(success));
    alert('success.'+success);   
  }, (error) => {
    alert('Error while storing file.'+JSON.stringify(error));
    alert('Error while storing file.'+error);
  });
}

you can direct save img in android gallery using file.externalrootdirectory

Thanks for your replay but sir, file.externalrootdirectory i have used this also but not shown in mobile gallery

use file.externalrootdirectory+"/Download/"+fileNameWithExt

file.externalrootdirectory+"/Download/" …yes i have used this link/download folder as wel but image is downloading successfully but not showing in gallery, actully i also used new local link to create new folder like i have given in my code i.e. “this.file2.externalRootDirectory +’/Foldername/Media/images/”

lastly i have done this, cheers ! i have used the media scanner plugin to update the downloaded images in gallery. :grinning:

cordova.plugins.MediaScannerPlugin.scanFile("device image link");