6

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.

Is this possible? How can I do this?

Thanks.

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
Jonovono
  • 3,437
  • 5
  • 42
  • 64
  • This similar question has an answer that looks promising: http://stackoverflow.com/questions/9717988/access-localstorage-or-web-database-created-in-phonegap-from-android-native-code – Anders Lindahl Apr 29 '12 at 05:48
  • Ya I found that but it doesn't seem to answer it. I can create the database and all but not sure how to then access it from the java code. This doesn't seem to show it... that code is for the jquery side. – Jonovono Apr 29 '12 at 05:53

1 Answers1

3

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.

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.

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.

Davide Vernizzi
  • 1,327
  • 17
  • 25