Phonegap从Java代码获取localstorage值? [英] Phonegap get localstorage values from Java code?

查看:457
本文介绍了Phonegap从Java代码获取localstorage值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用 localstorage 在手机客户端保存了数据,现在我希望使用java代码访问保存的数据。

I have saved data on the client side with phonegap using localstorage and now I would like to access that saved data with java code.

这是可能吗?

感谢。

推荐答案

你会在Android共享首选项中创建一个存储值的本地插件,并在每次在本地存储中添加/删除对象时调用它。

Why don't you make a native plugin that stores values in android shared preferences and call it each time you add/delete objects in the localstorage.

t直接调用localstorage函数,但是一个包装器1)操作localstorage,然后2)调用插件将其存储在共享首选项中。

So, in javascript you don't directly call the localstorage functions, but a wrapper which 1) manipulates the localstorage and then 2) calls the plugin to store it in the shared preferences as well.

当然这涉及到每个对象的双拷贝,所以你必须处理这个,但如果对localstorage的修改总是从javascript开始,这不应该是一个问题。

Of course this involves a double copy of each object, so you'll have to handle this too, but if modifications to the localstorage are always started from javascript this should not be a problem.

这篇关于Phonegap从Java代码获取localstorage值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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