1

I create a database in a phonegap application (android) and populate it with test values.

var db = window.openDatabase("achievements", "1.0", "AchievementsDB", 1000);
    db.transaction(createTables, function(tx, error){
        console.log("Error Creating Tables: "+error);
    }, function(){
        console.log("Successfully created Tables in Database");
    });

here is the createTables function

function createTables(tx){
tx.executeSql('CREATE TABLE IF NOT EXISTS Achievements (name unique, description)');  
tx.executeSql('INSERT INTO Achievements (name, description) VALUES (0, 1)');
tx.executeSql('INSERT INTO Achievements (name, description) VALUES ("good", "morning")'); 

}

the problem is. I always get the error Callback back. When I try a SELECT on the database it always says the retrieved data (the result data) is undefined. Also, I was wondering why I can´t access the data/data/mypackage/database folder of the phone (actually, DDMS just shows an empty data folder).

I really dont know anymore what´s the problem here I really googled and stackoverflowed a lot about this. Please give any help.

1 Answer 1

2

First of all Phonegap makes the database here

/data/data/package-name/app_database/file__0/0000000000000001.db

Secondly Where do you actually get the ErrorCallback in which query?

Sign up to request clarification or add additional context in comments.

7 Comments

hey, I get the error Callback on the "createTables" query. I can access the 000..01.db file on an emulator, not on a phone, but thanks anyway. The more important thing is why I can´t work with my database.
First of all try checking one query at one time... I suppose in the Create Table query,you need to specify the types of data for column like tx.executeSql('CREATE TABLE IF NOT EXISTS Achievements (name unique text, description text)');
I test only the first Query now. The decleration of the types didnt help, but upvote for some tips. It first called successcallback on creating tables. The Result of a select of the test data was still undefined. The Emulator says on the first query "error processing SQL".
oops my bad.. It should be like this tx.executeSql('CREATE TABLE IF NOT EXISTS Achievements (name unique text, description text)');
can´t find the difference, sorry :) Sometimes it really calls the SuccessCB, but still, when I execute a SELECT on the data, the result data is "undefined"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.