0

I'm making a phonegap app and using ydn-db there.

The problem is I don't want to do db = new ydn.db.Storage('db-name') all the time because it creates a new database. Is there a way to check if my database exists already ?

AdityaSaxena
  • 2,147
  • 11
  • 16

1 Answers1

1

you can also use to check below code.

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)');

}
Darshan
  • 2,272
  • 3
  • 31
  • 43