Access Web Storage Or IndexedDB From Outside The Browser In Android
Solution 1:
Unfortunately I don't think the data flow can work the way you want it. In the Chromium WebKit implementation, IDB stores data in levelDB files that you should not be able to access (by design).
So how do we get Java and JavaScript to play nice together? That's a great question! As I see it, the only good way to transform Java data into IDB data is via the client-side.
I've got good IDB chops but my Android experience is non-production. From what I understand of it, here's a proposed solution:
- collect data via native application views
- write a string to a file in your sandbox with the data stored as a JSON blob or in an
.html
<script>
attached to a JavaScript global - load a webview that can access a local URI like
file://android_asset/blah.json
and then run some IDB code to bulk insert it into IDB - use your IDB store to drive your web-based views
So the answer to "if and how the native app would access the browser's data store" would be: try the opposite. Architect it to let your browser access your native app data store.
Solution 2:
Easiest and most robust way to serialise all your records and load into your app when it first run.
Solution 3:
It's possible if you're willing to try a slightly different approach:
Pulling data from an HTML5 app is tricky but pushing data to a native app is easier. Your HTML5 app must have a native container. Does the container API include a way to access native ContentProviders? If not, can you add your own native code to the container to do that? Basically, if you can access ContentProviders then your native app need only implement a ContentProvider with insert privileges (which can be restricted to only your HTML5 app). After an insert, the native app can do whatever it wishes with the data, including broadcasting it to to other devices.
If you insist on pulling data from the HTML5 app, this may only be possible if the native and HTML5 app are actually the same app, and that is only possible if your container allows you to add your own native code. Then you will have direct access to the WebView's storage via the WebStorage class.
Post a Comment for "Access Web Storage Or IndexedDB From Outside The Browser In Android"