hi,
i m try to make app like note pad by phonegap database api.But it work
only if we drop and create table in each time of app works.So i can't
store data permentlt.I have added the code.please help
/
*...............................................................................

<!DOCTYPE html>
<html>
  <head>
    <title>Contact Example</title>

      <script type="text/javascript" charset="utf-8"
src="phonegap-1.0.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for PhoneGap to load
    //
   // document.addEventListener("deviceready", onDeviceReady, false);
    var html = "<ul>";
    // Populate the database
    //
    function populateDB(tx) {
                var val=document.getElementById('datafield').value;
                //alert(val);
      //tx.executeSql('DROP TABLE IF EXISTS newdataaa');
       tx.executeSql('CREATE TABLE IF NOT EXISTS newdataaa (id unique,
data)');

                qry='INSERT INTO newdataaa (id, data) VALUES (1,"'+val+'")';
       tx.executeSql(qry);
        tx.executeSql('INSERT INTO newdataaa (id, data) VALUES (2,
"Second row")');
    }

    // Query the database
    //
    function queryDB(tx) {
        tx.executeSql('SELECT * FROM newdataaa', [], querySuccess,
errorCB);
    }

    // Query the success callback
    //
    function querySuccess(tx, results) {
        var len = results.rows.length;
      //  alert("newdataaa table: " + len + " rows found.");
        for (var i=0; i<len; i++){
                //var row = results.rows.item(i);
            html += '<li>'+results.rows.item(i).data+'</li>\n';
            //alert("Rowsss = " + i + " IDsss = " +
results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
        }
        html +='</ul>';
        document.getElementById("mydata").innerHTML = html;
    }

    // Transaction error callback
    //
    function errorCB(err) {
        console.log("Error processing SQL: "+err.code);
    }

    // Transaction success callback
    //
    function successCB() {
        var db = window.openDatabase("Database", "1.0", "PhoneGap
newdataaa", 200000);
        db.transaction(queryDB, errorCB);
    }

    // PhoneGap is ready
    //
    function getDataFromForm() {
        var db = window.openDatabase("Database", "1.0", "PhoneGap
newdataaa", 200000);
        db.transaction(populateDB, errorCB, successCB);
    }

    </script>
  </head>
  <body>
 <textarea name="datafield" id="datafield" cols="55" rows=""></
textarea>
<input name="" type="button"  onclick="getDataFromForm()"/>
    <h1>Examplenew</h1>
    <p>Database</p>
    <div id="mydata"></div>
  </body>
</html>
/*............................................*.

app will work in we remov comment from //tx.executeSql('DROP TABLE IF
EXISTS newdataaa'); please help .

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to