0

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?

2
  • 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.html Commented 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... Commented Jan 23, 2012 at 9:42

3 Answers 3

1

For PhoneGap --SQLite you can use Pluggin available on GIT HUB. there is javafile also.please check out the link:Sqlite Database

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

Comments

1

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

1

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

2 Comments

thanks for your reply. but I am getting null pointer exception at appview in the following code WebView appView = (WebView) findViewById(R.id.webView1); MyToaster toaster = new MyToaster(this, appView); appView.addJavascriptInterface(toaster,"MyToaster");
just follow that it works perfectly fine for me. WebView appView = (WebView) findViewById(R.id.webView1); is not required i think

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.