-1

I have eclips with ibm worklight pulgin .I want to create a custom plugin to store shared preferences values in worklight . can we do do this?? please post the answer with small implementation for this.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Developer
  • 3
  • 2
  • Shared preferences between what? Which platform? What did you try thus far? – Idan Adar Jul 24 '15 at 04:28
  • i want to create custome plugin for mobile first project in worklight.I want the steps required for doing this. – Developer Jul 24 '15 at 05:02
  • You did not answer my question. Read again. What are you looking to share? what data type? Between what (several apps? same device? multiple devices?! what?). What is the intended platform (iOS, Android, ...). Did you at all try anything before writing this question? – Idan Adar Jul 24 '15 at 05:03
  • I want to share string values in the same application intended to android.I have tried this code function wlCommonInit(){ WL.App.addActionReceiver ("doSomething", actionReceiver); } function actionReceiver(received){ // Do something with the received data. alert (received.data.someProperty); } – Developer Jul 24 '15 at 05:12
  • and in .java file i wrote this code.JSONObject data = new JSONObject(); try { data.put("someProperty", 12345); } catch (JSONException e) { // handle it... } WL.getInstance().sendActionToJS("doSomething", data); after this when i open the application i got the alert 12345.Now i want this value to store in shared prefernces using custom plugin.how to do that? – Developer Jul 24 '15 at 05:18

1 Answers1

0

If all you're looking to do is to simply store data for the application to be later used in the same application, you can simply use HTML5 LocalStorage API or JSONStore.

LocalStorage: http://diveintohtml5.info/storage.html
JSONStore: http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.dev.doc/devref/c_jsonstore_overview.html

There is no need for anything custom if the above is what you're looking for.

In the comments you are attempting to use the Send Action API. I don't know how that is supposed to help you. If you want a working example of that, you can see one here: Android: MobileFirst sending data from Native to cross page

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • yeah,but my requirement is to do this with the help of custom plugin .can we create a custom plugin to do the same? – Developer Jul 24 '15 at 05:27
  • You can base your code on the Send Action example I have pointed you to at the bottom of my answer. You can also use Cordova plug-ins: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/adding-native-functionality/ – Idan Adar Jul 24 '15 at 05:28
  • so you mean to say that for shared preferences all we have to do is to use JSON object? – Developer Jul 24 '15 at 05:40