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 8861359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:28:32+00:00 2026-06-14T15:28:32+00:00

I am developping an Android Application (Android 4.1.2) with PhoneGap (Cordova 2.2.0). I am

  • 0

I am developping an Android Application (Android 4.1.2) with PhoneGap (Cordova 2.2.0).

I am using Cordova Storage API :

I am following different examples found on internet in order to learn how to manipulate a database on Android like this one Create Android App with SQLite using Phonegap + Jquery mobile

In fact, my problem is that I am not sure if the database is physically created on the real device (I am testing on real device running with Android 2.3):

  • I checked in the folder /data/ with file Explorer but it was collapsed and I couldn’t expand it (May be some System Administrator issues?! If it is the case, how can I become root?)
  • I checked directly on the phone, but I didn’t even find the Application directory! (Is it normal? )

=> So I am not sure if the Database was created, or not.

Why I am thinking that the database is not created?

In fact, everytime I launch my app the table is empty although I populated it earlier.

I have also this error in LogCat:

sqlite returned error code = 14 msg = cannot open file at source line 25467

I did some researches and i found that this code in onCreate function could solve the problem:

    WebSettings settings = super.appView.getSettings(); 
    settings.setJavaScriptEnabled(true); 
    settings.setDatabaseEnabled(true); 
    String databasePath = this.getApplicationContext().getDir("database", 
                           Context.MODE_PRIVATE).getPath(); 
    settings.setDatabasePath(databasePath); 

But it didn’t solve it.

My code is simple, I read a QR-Code and I save it in a Table with the location:

var scanCode = function() {
    window.plugins.barcodeScanner.scan(
        function(result) {  
        alert("Scanned Code: " + result.text 
                + ". Format: " + result.format
                + ". Cancelled: " + result.cancelled);
        getPosition(result.text);
    }, function(error) {
        alert("Scan failed: " + error);
    });
}

function getPosition(data) {
    navigator.geolocation.getCurrentPosition(
            function(position, result){
                launchDB();
                latitude = position.coords.latitude;
                longitude = position.coords.longitude;
                db.transaction(function(tx) {
                    tx.executeSql("insert into DEMO(code,updated, latitude, longitude) values(?,?,?,?)",[data, new Date(),latitude, longitude]);
                },errorCB,successInsert);
            }, positionError);
}

function launchDB() {
    console.log("launchDB()");
    db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
    db.transaction(setupDB, errorCB);
}

function setupDB(tx) {
    console.log("setupDB()");
    tx.executeSql('DROP TABLE IF EXISTS DEMO');
    tx.executeSql("CREATE TABLE IF NOT EXISTS DEMO(id INTEGER PRIMARY KEY,code,updated, latitude, longitude)");
}

function errorCB(err) {
    console.log("Error processing SQL: "+err.code);
}

function successInsert() {
    console.log("successInsert()");
}

And I try to display the rows in another page:

function showCode() {
    console.log("showCode()");
    db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
    db.transaction(parseDB, errorCB);
}

function parseDB(tx) {
    console.log("parseDB()");
    tx.executeSql('SELECT * FROM DEMO', [], writeEntries, errorCB);
}

function writeEntries(tx, results) {
    console.log("writeEntries()");
    var len = results.rows.length;
    document.write("DEMO table: " + len + " rows found.");
    console.log("DEMO table: " + len + " rows found.");
    for (var i=0; i<len; i++){
        document.write("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).code + " Latitude =  " + results.rows.item(i).latitude+ " Longitude =  " + results.rows.item(i).longitude );
        console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).code + " Latitude =  " + results.rows.item(i).latitude+ " Longitude =  " + results.rows.item(i).longitude);
    }
}

In the log, I can see the row created. But in the html page not (But it is another issue: JQuery issue). But when I try to add another row, the first row does not exist any more.

Thank you for your help.

  • 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-14T15:28:34+00:00Added an answer on June 14, 2026 at 3:28 pm

    It looks like setupDB is getting called every time you call launchDB and dropping the table if it exists.

    There could also be some separate issues with the file access, but that drop table would be the first thing to fix.

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

Sidebar

Related Questions

Am developing a android application using phonegap(Cordova 2.0.0). I need the retrieve the device
I am developing an application for Android using PhoneGap (Cordova 1.6.1). My application crashes
I am developing an application using phonegap for both ios and android. My application
I am developing an Android application using Phonegap . I need to make the
I am developing a mobile application in android using eclipse and phonegap. and my
I am developing an android app using phonegap (cordova-2.1.0). My MainActivity.java code is as
I am developing android application using phonegap. I am using only one HTML page(index.html).
I am developing an app using phonegap for Android. I want this mobile application
hi i am developing an android application using phonegap and i have come across
Good evening, I am currently developing an application for android using phonegap and sencha

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.