Delete image from device Ionic


#1

Using Ionic 3 File pkugin for removing images from device,

 deleteFromDevice(data){

      for(let i=0; i<data.rows.length; i++){
        this.file.removeFile(data(i).location, data(i).picture).then(_ => console.log('deleted')).catch(err => console.log('cannot delete'));
        }
        }, (error) => {
            console.log("Error: " + JSON.stringify(error.err));
        }); 
  }

Above function deletes images content but file remains on device with exclamation mark. Anyone familiar with this?


#2

@markedjani yes the process is quite painful especially on Android. Only solution I found was similar to yours, but be careful if you have observables, promises, or listeners on anything related to these files, TypeScript will not process the delete message, and stay silent (it’s considered your own design fault). So make sure every potential 2 way data binding thing is well closed before that.