Saturday, August 20, 2011

Re: [android-developers] how can i get the data created by function openDatabase from the webview?

On Sat, Aug 20, 2011 at 8:18 AM, 李白|字一日 <calidion@gmail.com> wrote:
> hello everyone,
> i have a problem in retrieving data stored in webview by using html
> database.
> and it is working perfectly on the html page.
> as the application involves, there is a demand that i get the stored data
> from the webview.
> after investigating into the sdk, i didn't find a way to get the data,
> because the webview database is named privately with names like
> "0000000000000001.db"
> and in directories like
> "file__0".
> i only set the database path by the following code:
>     databasePath = this.getApplicationContext()
>         .getDir("database", Context.MODE_PRIVATE).getPath();
>     settings.setDatabasePath(databasePath);
> which is different from the "0000000000000001.db" file name, and "file__0"
> directory name.
> so i can get the database data using given apis?

I doubt it.

Rather than having the JavaScript use an HTML database, you should
have the JavaScript call an API your application exposes to the
WebView via addJavascriptInterface(). This will allow you to keep all
your business rules in the Java code, with a side benefit of being
able to consistently use SQLiteOpenHelper and such for accessing the
database.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.6 Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate