访问Web存储或IndexedDB的针对Android的浏览器之外 [英] Access Web Storage or IndexedDB from outside the browser in Android

查看:564
本文介绍了访问Web存储或IndexedDB的针对Android的浏览器之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用HTML和JavaScript来收集有关Android平板电脑的调查数据建立一个基于浏览器的应用程序离线。该应用程序将包括与形式让用户输入数据的一些静态页面,那么这将使用Web存储或IndexedDB的本地存储的。不过,我也想建立一个小的原生Android应用程序,它会抓住这个数据,并将其转移到其他设备上。这是可能的,如果是这样我会怎么做呢?

I want to build an offline browser-based app using HTML and javascript to collect survey data on Android tablets. The app would consist of some static pages with forms for users to enter data, which would then be stored locally using Web Storage or IndexedDB. However, I also want to build a small native Android app which would grab this data and transfer it to other devices. Is this possible, and if so how would I go about it?

我特别想了解是否和本机应用程序将如何访问浏览器的数据存储(我可以管理的其余部分)。我想preFER使用Android浏览器,但可以使用任何其他如果这使得它更容易。我发现这博客帖子这表明这是可能的,但我会AP preciate一些指针,以其中的数据是由Android浏览器,以及如何轻松它可以由另一个应用程序可以访问存储。

Specifically, I want to understand if and how the native app would access the browser's data store (I can manage the rest). I would prefer to use the Android browser but can use any other if that makes it easier. I have found this blog post which suggests that it might be possible but I would appreciate some pointers as to where the data is stored by the Android browser and how easily it can be accessed by another app.

推荐答案

不幸的是,我不认为该数据流可以工作,你想要的方式。在铬WebKit的执行情况,性LevelDB IDB文件存储数据,你不应该能够访问(设计)。

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).

那么,我们如何获取Java和JavaScript发挥好起来呢?这是一个很大的问题!在我看来,转换Java数据到IDB数据的唯一好方法是通过客户端。

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.

我已经得到了很好的IDB印章,但我的Andr​​oid体验就是非生产。从我了解的话,这里有一个建议的解决方案:

I've got good IDB chops but my Android experience is non-production. From what I understand of it, here's a proposed solution:


  • 通过收集本机应用程序视图中的数据

  • 将一个字符串写入一个文件中存储作为JSON BLOB或在的.html &LT数据沙箱;脚本> 连接到一个JavaScript全球

  • 加载网页视图,能够访问本地URI像文件://android_asset/blah.json 然后运行一些IDB code批量将其插入IDB

  • 使用您的IDB店里来驱动你的基于Web的意见

  • 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.

这篇关于访问Web存储或IndexedDB的针对Android的浏览器之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆