Skip to content

Populating Cordova SQLite storage with the JQuery API


For review, you should have the following code in the the onDeviceReady function in www/js/index.js:

    var db = window.sqlitePlugin.openDatabase({name: "test.db"});
    db.executeSql("DROP TABLE IF EXISTS tt");
    db.executeSql("CREATE TABLE tt (data)");

      url: '',
      dataType: 'json',
      success: function(res) {
        console.log('Got AJAX response: ' + JSON.stringify(res));
        $.each(res, function(i, item) {
          $.each(data, function(i, item) {
            console.log('item: ' + JSON.stringify(item));
            tx.executeSql("INSERT INTO tt values (?)", JSON.stringify(item));
        }, function(e) {
          console.log('Transaction error: ' + e.message);
          alert('Transaction error: ' + e.message);
        }, function() {
          db.executeSql('SELECT COUNT(*) FROM tt', [], function(res) {
            console.log('Check SELECT result: ' + JSON.stringify(res.rows.item(0)));
            alert('Transaction finished, check record count: ' + JSON.stringify(res.rows.item(0)));
      error: function(e) {
        console.log('Got ERROR: ' + JSON.stringify(e));
        alert('Got ERROR: ' + JSON.stringify(e));


No Trackbacks


Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Form options

Submitted comments will be subject to moderation before being displayed.