vendredi 6 février 2015

Do we really need to add sqlite plugin in cordova..?

I am using corodova 4.X to create my android application and i'm planning to use sqlite in my app. Do i really need to add the sqlite plugin in my app in order to use it.


I've tried to creating a database without adding the sqlite plugin it works fine, i can able to insert and view the contents.





<script>

document.addEventListener("deviceready",onDeviceReady,false);

function onDeviceReady() {
database = window.openDatabase("Test","1.0","Testing Select",200000);
database.transaction(PopulateDatabase,errorDB,successDB);
}


function PopulateDatabase(tx){
tx.executeSql("Create Table IF NOT EXISTS Test (ROLLNO INT, Lastname text, Firstname text, PhoneNo text)");
tx.executeSql("Insert into Test values(1,'XX','YY','1234567844')");
tx.executeSql("Insert into Test values(2,'AA','BB','1234567890')");

}


</script>



My Question is : 1. The way i did is correct or wrong. ? 2. Will the database is actually created or it's just a text file which created. 3. Do i really need to add the sqlite plugins. ?


Aucun commentaire:

Enregistrer un commentaire