how i create/open database in android?

Go To StackoverFlow.com

0

i am using PhoneGap,n using this code in xCode then run properly and database show in, iphone simulator-->5.0-->Applications--> (application name) --> Webkit --> Database

But when i us in Eclipse, then it not create any database in ddms->data->data->database. how it work proper. Suggest me

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

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

    // Wait for PhoneGap to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

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

    // Populate the database 
    //
    function populateDB(tx) {
         tx.executeSql('DROP TABLE IF EXISTS DEMO');
         tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
         tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
    }

    // Transaction error callback
    //
    function errorCB(tx, err) {
        alert("Error processing SQL: "+err);
    }

    // Transaction success callback
    //
    function successCB() {
        alert("success!");
    }

    </script>
  </head>
  <body>
    <h1>Example</h1>
    <p>Database</p>
  </body>
</html>
2012-04-05 15:45
by MRT
this is example of link. this sit - MRT 2012-04-05 15:48


0

DDMS does not have access to the /data directory. See these these two stackoverflow discussions for workarounds:

2012-04-06 18:34
by Paul Beusterien
DDMS have access to /data directory. But PhoneGap doesn't storage db files at /data/data/com.application/databases. It storages at /data/data/com.application/app_database - tersakyan 2012-10-08 19:27
Ads