Duplicating when closing when reopening app

    let prontuario = localStorage.getItem('matricula') ? localStorage.getItem('matricula') : sessionStorage.getItem('matricula');
    return this.dbapp.getDB()
    .then((db: SQLiteObject) => {
      db.executeSql(`select * from agendamento where prontuario = ${prontuario} `, [])
       .then((data) => {
        for (let i = 0; i < data.rows.length; i++) {
          let dados = data.rows.item(i);
          //console.log('Data Return: ' + dados)

        }).catch((e) => console.error(e));

    }).catch((e) => console.error(e));


Why are you not resetting localStorage and sessionStorage value? i think if you reset that local store and session values after completing for loop. when you will reopen it, you will not receive any duplicate entries.

Using localStorage doesn’t make sense to me. You should be using ionic storage.