This is a migrated thread and some comments may be shown as answers.

SQLite run on iPad Mini

3 Answers 46 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keen
Top achievements
Rank 1
Keen asked on 11 Jun 2013, 08:35 AM

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

var app = {};
app.db = null;
    
app.openDb = function() {
    if(window.sqlitePlugin !== undefined) {
        app.db = window.sqlitePlugin.openDatabase("XXXXXX");
        alert("SQLITE");
    } else {
        // For debugin in simulator fallback to native SQL Lite
        console.log("Use built in SQL Lite");
        app.db = window.openDatabase("XXXXXX", "1.0", "Cordova Demo", 200000);
    }
}
    
app.createTable = function() {
 var db = app.db;
 db.transaction(function(tx){
//creating table here    
});  
}
function init() {
    navigator.splashscreen.hide();
 app.openDb();
 app.createTable();

}



I declare this on my Main JS,. I follow whats on the SQLite sample. when I run SQLite sample its save on local. but in my codes with same declaration. Its doesn't run creating the SQLite.
What would be the problem?
My declaration of plugin is ok like on the sample SQLite.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 12 Jun 2013, 10:53 AM
Hello Keen,

You're missing executeSql statement to create the database. If you're still having problems, we suggestg you debug your code by adding alerts or console.log. Our sample is based on the explanation from this post (A Simple TODO list using HTML5 WebDatabases), so if you're unsure about something, we suggest reviewing it first.

Regards,
Steve
Telerik

Looking for tips & tricks directly from the Icenium team? Check out our blog!
Missed our first webinar, watch it here.
Share feedback and vote for features on our Feedback Portal.
0
Keen
Top achievements
Rank 1
answered on 13 Jun 2013, 01:40 AM
Hi Steve,

Everything works now, But ive got a problem in simulator of graphite, im using loop to insert data to SQLite but it failed to put data, But when I used window.setinterval every .650 milliseconds, it save.. Is it a bug or not? Its ironic to think that  loop is faster but it doesn't save..
0
Steve
Telerik team
answered on 13 Jun 2013, 11:31 AM
Hi Keen,

I can't reproduce this locally, I've changed the addTodo function of the sample-sqlite demo like so for the test :

function addTodo() {
    var todo = document.getElementById("todo");
        for (var i = 0; i < 5; i++) {
            todo.value = i + 1;
            app.addTodo(todo.value);
        }
     
    todo.value = "";
}


Regards,
Steve
Telerik

Looking for tips & tricks directly from the Icenium team? Check out our blog!
Missed our first webinar, watch it here.
Share feedback and vote for features on our Feedback Portal.
Tags
General Discussion
Asked by
Keen
Top achievements
Rank 1
Answers by
Steve
Telerik team
Keen
Top achievements
Rank 1
Share this question
or