Database Woes

1,122 views
Skip to first unread message

Fabián Mandelbaum

unread,
May 19, 2012, 8:15:01 AM5/19/12
to phon...@googlegroups.com
Hello, starting with Phonegap and tablets and already hitting my head against the wall :-)

Development environment: Eclipse + Android SDK (Mac OS X), Android 4.0.3, Phonegap 1.7.0

I've read that the application's database should be stored under /data/data/app_name/databases/db_name

I'm using the window.openDatabase API PG call and seeing on Eclipse's LogCat console the following, as soon as my app starts:

05-19 08:38:07.170: I/SqliteDatabaseCpp(1449): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/com.giant.gros/databases/webview.db

05-19 08:38:07.170: I/SqliteDatabaseCpp(1449): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.giant.gros/databases/webview.db

A few issues with this:

1) My DB is not called webview.db, so why is the log entry about the PG app attempting to open it?
2) Using both Eclipse's Android SDK File Explorer view and the Tablet's own File manager, I cannot see anything under /data, shouldn't there be a DB file if not with my name at least with webview.db?
3) Probably not phonegap specific, forgive me if it's OT, but: which tool(s) can I use (and how?) to check the databases on the device?

Other DB calls do not run the error callback, so they seem to work OK... how comes it works if there's no DB?

There's also a post from me about transaction errors when trying to access the DB...

Help is appreciated, thanks in advance!

Simon MacDonald

unread,
May 21, 2012, 10:06:36 AM5/21/12
to phon...@googlegroups.com
Well

1) You can safely ignore:

05-19 08:38:07.170: I/SqliteDatabaseCpp(1449): sqlite returned: error
code = 14, msg = cannot open file at line 27701 of [8609a15dfa],
db=/data/data/com.giant.gros/databases/webview.db

as that is a log you see every time a WebView is instantiated in Android.

2) It is a UNIX filesystem so the permissions don't let you easily see
what's in /data but if you go to /data/data/{package name} they you'll
be able to see your apps files as you'll have the permissions to see
it but you have to know the directory name ahead of time.

3) Usually I will do "adb shell" to get a UNIX terminal into my phone
then "cd" into my apps directory. If you want to inspect your DB on
the device you can use the "sqlite" command.

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Fabián Mandelbaum

unread,
May 21, 2012, 4:36:52 PM5/21/12
to phon...@googlegroups.com
Hello Simon, thanks for your answer, here's mine, between lines:


On Monday, 21 May 2012 11:06:36 UTC-3, Simon wrote:
Well

1) You can safely ignore:

05-19 08:38:07.170: I/SqliteDatabaseCpp(1449): sqlite returned: error
code = 14, msg = cannot open file at line 27701 of [8609a15dfa],
db=/data/data/com.giant.gros/databases/webview.db

as that is a log you see every time a WebView is instantiated in Android.

 
OK.
 
2) It is a UNIX filesystem so the permissions don't let you easily see
what's in /data but if you go to /data/data/{package name} they you'll
be able to see your apps files as you'll have the permissions to see
it but you have to know the directory name ahead of time.


Well, this is the problem, I've tried to ls /data/data/com.giant.gros and got no files/folders there,
I've tried every combination I could think of using the full package name, the full class name, etc. as possible folders inside /data/data, but still no luck.
 
3) Usually I will do "adb shell" to get a UNIX terminal into my phone
then "cd" into my apps directory. If you want to inspect your DB on
the device you can use the "sqlite" command.


Which would be the "apps directory"? (As an android path, if possible, thanks).
 
Thanks for your answers, hope you can answer these new questions!

Simon Mac Donald
http://hi.im/simonmacdonald


On Sat, May 19, 2012 at 8:15 AM, Fabián Mandelbaum

Simon MacDonald

unread,
May 22, 2012, 12:53:13 PM5/22/12
to phon...@googlegroups.com
It's odd that you don't see anything in /data/data/{package name}.
When you create a new DB using window.openDatabase with PhoneGap it
will be created in /data/data/{package name}/database.

Simon Mac Donald
http://hi.im/simonmacdonald


Fabián Mandelbaum

unread,
May 22, 2012, 2:34:35 PM5/22/12
to phon...@googlegroups.com
Hello, I finally see something there:

shell@android:/ $ ls -l /data/data/com.giant.gros/databases/webview.db         
-rw-rw---- app_1    app_1       12288 2012-05-22 15:26 webview.db
shell@android:/ $ 

Now, I guess that the only way I have to manipulate that file is by rooting my tablet (which I'd like to avoid, if possible). I've tried to pull that file to my machine with:

./adb pull /data/data/com.giant.gros/databases/webview.db .

only to be greeted with:

failed to copy '/data/data/com.giant.gros/databases/webview.db' to './webview.db': Permission denied

I've also tried to run the sqlite and sqlite3 commands on the tablet, to no avail (and I doubt I'd be able to access the DB on under /data, I've also installed a 'db browser' app from the market, and I don't have access to the DBs under /data, which is kinda expected because of permissions).

So, I guess the only way I'll be able to work with that file is by rooting my tablet?

This is turning OT, but I'd like to hear your answer, if possible. Thanks in adavance!

On Tuesday, 22 May 2012 13:53:13 UTC-3, Simon wrote:
It's odd that you don't see anything in /data/data/{package name}.
When you create a new DB using window.openDatabase with PhoneGap it
will be created in /data/data/{package name}/database.

Simon Mac Donald

On Mon, May 21, 2012 at 4:36 PM, Fabián Mandelbaum

Simon MacDonald

unread,
May 22, 2012, 2:36:51 PM5/22/12
to phon...@googlegroups.com
Actually, look under /data/data/com.giant.gros/app_database as well.
Perhaps you are using an older version of PG where the path was
different. Yes, if you want to edit that file you'll need root privs.

Why don't you run you app in the emulator where you do have root
access and you'll be able to use sqlite to view the contents of the
db?

Simon Mac Donald
http://hi.im/simonmacdonald


Fabián Mandelbaum

unread,
May 22, 2012, 2:58:38 PM5/22/12
to phon...@googlegroups.com
Hello Simon,

first, let me thank you for your answers.

Tried to look there, got this:

shell@android:/ $ ls -l /data/data/com.giant.gros/app_database
opendir failed, Permission denied
1|shell@android:/ $ ls -l /data/data/com.giant.gros/app_database.db            
/data/data/com.giant.gros/app_database.db: No such file or directory
1|shell@android:/ $ ls -l /data/data/com.giant.gros/app_database/webview.db    
/data/data/com.giant.gros/app_database/webview.db: No such file or directory
1|shell@android:/ $ ls -l /data/data/com.giant.gros/app_database/giant.db      
/data/data/com.giant.gros/app_database/giant.db: No such file or directory
1|shell@android:/ $

Why I don't run my app on the emulator? Because it's very slow :)

I'm using phonegap 1.7.0 BTW

Thanks again, will try to root my tablet... =X

Jay

unread,
Jan 12, 2013, 12:52:09 PM1/12/13
to phon...@googlegroups.com
I don't understand where /data/data is? I am on a mac. Is that supposed to be relative to the project directory? I am confused. I always get these cannot open file /CachedGeoposition.db errors

Simon MacDonald

unread,
Jan 15, 2013, 9:05:24 PM1/15/13
to phonegap
/data/data is on the Android device.

It is safe to ignore the cannot open file /CachedGeoposition.db log.

Simon Mac Donald
http://hi.im/simonmacdonald


> --
> -- You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>
> To compile in the cloud, check out build.phonegap.com
>
>

adeelah...@gmail.com

unread,
Apr 20, 2013, 3:38:01 AM4/20/13
to phon...@googlegroups.com
hi Simon,

I am new to phonegap and android I am developing a application of Android Uisng phonegap html 5 and javascript with jquerymobile. This application is not web application it will install in the device.
I am developing a application of Android Uisng phonegap html 5 and javascript with jquerymobile. This application is not web application it will install in the device. I have some reports in this application i want to convert html content of the reports in the pdf and download it in local device. I have tried jspdf plugin but it doesnot works fine can any body help me in this regard i am stuck with this issue since last week i will be very thankfull to you people. kindly help me and sory for my bad english if you found any mistakes in writing the problem. :-)
this is query i have posted on serveral forums

the code i am using is as under

i have two functions one to open child browser as given below

  function childbrowser()
        {
        alert("childbrowser");
        alert(window.location.href);
        window.plugins.childBrowser.showWebPage(window.location.href, { showLocationBar: true });
        }

and other to download the generated pdf..


  function downloadpdf()
        {
         
        try {
           //  var doc = new jsPDF();
           
           var htmlcontent="<!doctype><html><head><title>jsPDF</title></head>"+$('#mybody').html()+"</html>";
           
            var pdf = new jsPDF('p','in','letter')
            ,source = htmlcontent;
   
    specialElementHandlers = {
    // el ement with id of "bypass" - jQuery style selector
    '#bypassme': function(element, renderer){
    // true = "handled elsewhere, bypass text extraction"
    return true
    }
    }
            //  doc.text(20, 20, 'This PDF has a title, subject, author, keywords and a crea');
           //  alert(doc.output());
           pdf.fromHTML(
    source // HTML string or DOM elem ref.
    , 0.5 // x coord
    , 0.5 // y coord
    , {
    'width':7.5 // max width of content on PDF
    ,'elementHandlers': specialElementHandlers
    }
    )
   
    alert(window.location.href);
          pdf.addPage();
      
          // var out= pdf.output('datauri');
      //  navigator.saveAs(htmlcontent, 'mmmmmmm.pdf');
      
      
        pdf.save('adeel.pdf');
       // alert("out   "+out); 
        
        // var out = jsPDF.output();
        //  var url = 'data:application/pdf;base64,' + btoa(out);
         //  document.location.href = url;
   
      //  pdf.save('adeel.pdf');
   
   
        } catch (e) {
           return e.message;
       }
       return ""; 
         
        }
         

it works fine in the browser of my system but not in the virtual tablet device in which application is install it gives the following error in the green .


04-20 12:26:22.515: I/SqliteDatabaseCpp(759): sqlite returned: error code = 14, msg = cannot open file at line 27701 of [8609a15dfa], db=/data/data/com.example.energy_e360/databases/webview.db

04-20 12:26:22.465: I/SqliteDatabaseCpp(759): sqlite returned: error code = 14, msg = os_unix.c: open() at line 27701 - "" errno=2 path=/CachedGeoposition.db, db=/data/data/com.example.energy_e360/databases/webview.db


any help will be appreciated.



Reply all
Reply to author
Forward
0 new messages