Access localStorage or web database created in PhoneGap from Android native code
Asked Answered
I

2

5

How is it possible to access Web SQL database created in PhoneGap app from native code in Android?

I have a local notification plugin set up and what I want to achieve is fetch user setting from web database to set a correct interval for my alarm.

Interlink answered 15/3, 2012 at 10:36 Comment(0)
I
-1

Easiest solution seems to be to create a shared preference plugin, should work well with small and simple data.

Interlink answered 24/5, 2012 at 20:16 Comment(0)
H
1

I have modified the Cordova(https://github.com/Coder-Nasir/incubator-cordova-android) in such a way that it will create the database in Android's Default location which is /data/data/package-name/databases/

By just this simple command

window.openDatabase("something", "1.0", "PhoneGap Demo", 0);

You will get your desired something.db in the above mentioned location..

Herra answered 15/3, 2012 at 10:43 Comment(8)
the code changes you've made make sense... as long as google won't change the path. But the main problem still is that I have you open database in my android native code, plugin. The code example you gave is for javascript side. By the way, where does phonegap normally deploy the database on device. I cannot find it when debugging.Interlink
Yes so its easy to open the database with the native Code.Since it is in the default path right?... And Phonegap uses webview database and stores it in /data/data/packagename/app_database/file__0/00000000000000001.dbHerra
hmm.. somehow in eclipse when i try to look for my database file in DDMS i can't find it anywhere. The whole data folder is empty. This is using the phonegap-1.3... do you know how to find it?Interlink
Go to DDMS--->File Explore--->data----->data---->Packagename---->app_database---->file__0Herra
that is exactly where I tried to look it for. As I earlier stated, the whole data folder is empty, although my database is successfully created in my script. Using HTC Wildfire S for testing. I also can fetch things from my database but still can't find it anywhere.Interlink
@Coder_sLaY: using this library will i be able to acces my android app database from /data/data/appPackage/databases/ ?? Or will it createa like cordova or basic javascript code its own db & the ugly - /file__0/00000000000000001.db ??Hypercriticism
@Hypercriticism you will be able to get from android default database location ./databases/ with a database name you preferHerra
i know i am too late but this link will help someone else .... https://mcmap.net/q/1924416/-where-is-my-app-data-appears-emptyTelemetry
I
-1

Easiest solution seems to be to create a shared preference plugin, should work well with small and simple data.

Interlink answered 24/5, 2012 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.