2 Replies Latest reply on Jun 22, 2017 5:16 AM by ianm87404462

    Has anyone here ever made a "phone gap" application with database access?

    raphaelluiz128

      I am testing a code, however I can only save information in the browser, when I test on the mobile I can not save.

       

       

       

      file banco.js

       

      it's work in browser but not in mobile.

       

      ---

       

       

      window.addEventListener('load', carregado);

      var db = openDatabase("myDB", "1.0", "TiPS Database Example", 2 * 1024 * 1024);

      function carregado(){   

         

          document.getElementById('btn-salvar').addEventListener('click', salvar);

          document.getElementById('btn-deletar').addEventListener('click', deletar);

         

          db.transaction(function(tx) {

             

              tx.executeSql("CREATE TABLE IF NOT EXISTS myTable ( id INTEGER PRIMARY KEY,nome TEXT,senha TEXT, email TEXT)" );

      //       

          });

         

          mostrar();

         

      }  

       

       

      function salvar(){

          var id = document.getElementById('field-id').value;

          var nome = document.getElementById('field-name').value;

          var pass = document.getElementById('field-pass').value;

          var mail = document.getElementById('field-mail').value;

       

       

          db.transaction(function(tx) {

              if(id){

                  tx.executeSql('UPDATE myTable SET nome=?, senha=?, email=? WHERE id=?', [nome,pass,mail,id],null);

              }else{

                  tx.executeSql('INSERT INTO myTable ( nome,senha,email) VALUES (?, ?, ?)', [nome,pass,mail]);

              }

          });

       

       

          mostrar();

          limpaCampo();

          inputSHOW(false);

      }