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

  • Home
  • SEARCH
  • 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 7904105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:54:53+00:00 2026-06-03T09:54:53+00:00

I followed a phonegap tutorial on how to set up and create an SQLite

  • 0

I followed a phonegap tutorial on how to set up and create an SQLite DB on my android tablet. The DB is written in javascript, and the application is written in HTML5.

The DB became really big in the end (1200 lines only with populating/adding data)
One of my concerns is that it populates everytime I go to my index.html (frontpage) or a page I called catalog.html.
Is this a problem for memory or time etc? the application do not add any content to the DB while running.
do anyone know of a way to NOT let it populate every time?
Here is some of the code:

document.addEventListener("deviceready", onDeviceReady, false);
var db = window.openDatabase("DBfile", "1.0", "Afghanistan", 200000);

function onDeviceReady() {
    db.transaction(populateDB, errorCB, successCB); 
}
function populateDB(tx) {
    (...
    ...
    ...)
}
function errorCB(tx, err) {
    alert("Error processing SQL: "+err.code);
}
function successCB() {
    alert("DB and tables generated with success!");
}

Will it help to only “link” to the db-file in index.html instead of all the other pages?
the strange thing is that there is also one other page that get data from the DB file, but I do not get an “DB and tables generated with success!” alert when I enter that page.

  • 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-03T09:54:55+00:00Added an answer on June 3, 2026 at 9:54 am

    The way you have your code structured the populateDB method will be called every time you start your app. You will want to guard this call by setting a value in localStorage. Something like:

    function onDeviceReady() {
        if (localStorage.getItem("firstRun") == null) {
            db.transaction(populateDB, errorCB, successCB);
            localStorage.setItem("firstRun", false);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying out PhoneGap, so I followed the instructions to create an Android Project
I followed this tutorial to create a sample Login application using ASP.NET MVC I
I followed this tutorial to create a color state list for a particular Android
I followed the HTML5 Websocket tutorial of the website below: http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ It worked well,
I followed the first tutorial of Phonegap - getting started with Android. I wrote
I have started to working with phoneGap application for android. I followed the steps
I followed their how-to: Phonegap Start Phonegap wiki I have succesfully installed the android
I followed this tutorial and I'm currently trying to create a class to draw
I followed the steps of this tutorial: http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/ to install the Android NDK on
I followed this tutorial for uploading a file in my JSF2 application. The application

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.