Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:41:14+00:00 2026-06-07T12:41:14+00:00

Please excuse me if this is something simple I am overlooking. I am making

  • 0

Please excuse me if this is something simple I am overlooking. I am making my first foray into app development using the PhoneGap/Cordova platform, I appear to be stuck at the first hurdle. My deviceReady listener doesn’t appear to be firing.

My code looks like so:

alert('0');

document.addEventListener("deviceready", function(){
    alert('1');
    db = window.openDatabase("testproject", "1.0", "PhoneGap Test", 200000);
    alert('2');
    if (dbCreated){
        alert('3');
        db.transaction(getData, transaction_error);
    } else {
        alert('4');
        db.transaction(populateDB, transaction_error, populateDB_success);
    }
}, false);

the initial alert('0') (put in to make sure I am actually connecting to the file) is firing but nothing else is happening.

In another post on here. Someone else with a similar problem was promted to try document.addEventListener("deviceready", deviceReadyFunction, true) which solved the issue for them, but not for me.

As a side question, how do you go about debugging javascript and inspecting the clientside databases in PhoneGap development? When developing for the web I obviously have firebug and many other tools, however with PhoneGap dev relying heavily on deviceready which is not triggered by a browser are there any tools I should be aware of? (I am writing my code in Coda but compiling from Xcode).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:41:15+00:00Added an answer on June 7, 2026 at 12:41 pm

    I have together the code and it works fine, i have tested using Cordova 1.7 and Android 2.2

        var dbCreated = false;
        document.addEventListener("deviceready",
                function() {
                    alert('1');
                    db = window.openDatabase("testproject", "1.0", "PhoneGap Test",
                            200000);
                    alert('2');
                    if (dbCreated) {
                        alert('3');
                        db.transaction(getData, transaction_error);
                    } else {
                        alert('4');
                        db.transaction(populateDB, transaction_error,
                                populateDB_success);
                    }
                }, false);
    
        function getData() {
    
        }
    
        function transaction_error() {
    
        }
    
        function populateDB(tx) {
    
        }
    
        function populateDB_success() {
    
        }
    

    Full source code – https://gist.github.com/3064728

    For debugging, use weinre it is a really good tool to debug javascript applications on mobile devices.

    http://people.apache.org/~pmuellr/weinre/docs/latest/

    PhoneGap is also using it via – debug.phonegap.com

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first post on stackoverflow, so please excuse me if my question
this was my first dojo build so please excuse my ignorance in this matter.
please excuse me if i am not stating this correctly or using correct terminology
I am being thick this morning so please excuse this simple question - I
Please excuse me if this is a very simple solution or stupid mistake -
This is the first time I've used Node.js and Mongo, so please excuse any
I am a patterns newbie so please excuse this question if it sounds too
I am rather new to wx/python so please excuse if this is stupid or
I am new to jquery so please excuse me if this question seems silly...
I'm new to C# and WinForms so please excuse me is this is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.