I have created sqlite database using phonegap. I am able to access that databse within the javascript. But I want access that sqlitedatabase from java class. It is possible?
-
Is phone gap that web development thing? If so you'll need to load your sqlite stuff through code that is then compiled. There's loads of stuff about this online: vogella.de/articles/AndroidSQLite/article.htmlingh.am– ingh.am2012-01-23 09:41:58 +00:00Commented Jan 23, 2012 at 9:41
-
Are you really accessing your database through javascript though? This seems rather insecure but I'm not experienced enough with phone gap to say it for sure...ingh.am– ingh.am2012-01-23 09:42:45 +00:00Commented Jan 23, 2012 at 9:42
3 Answers
For PhoneGap --SQLite you can use Pluggin available on GIT HUB. there is javafile also.please check out the link:Sqlite Database
Comments
I don't know about PhoneGap compatibility, but, as far as Android, WebView control and JavaScript is concern, you do have a solution.
You should consider using WebView's addJavascriptInterface.. This will expose any of your Java objects as a JavaScript object. So, you could create a class that encapsulate the SQLite functionality you want expose and sent it through.
Comments
As said above in the answer by BicycleDude. U need to create a class and expose it and use it inside javascript.
http://groups.google.com/group/phonegap/browse_thread/thread/eb9c4a350482f86f
This link contains the reference to make toast inside javascript.U can use this similarly to access database.One problem is how u handle the returned cursor.may be u can use JSON