Karry
Karry

Reputation: 153

How to access Codename one Preferences from Android Native code?

I am using native code to check for IAP purchases and need to store the results in the Preferences. When I store them in the Android SharedPreferences, the Codename one Preferences can't find it. Are they implemented differently? And if so, is there a way to either access the Codename One Preferences from native code? Here is the code I am using in the Android native code to store something in SharedPrefs:

SharedPreferences sharedPref = activity.getPreferences(android.content.Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString("TIER_SKU", msg);
        editor.commit();

But like I said. When accessing Preferences using the same key, it can't be found back in the Codename One code.

Upvotes: 2

Views: 178

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

They are completely different. You can use the Codename One API directly from native Android code so a call to Preferences should work just fine.

The one thing to keep in mind though is the threads issue so if you call Codename One API you should be aware of whether you are on the EDT or not and the same applies to the Android native thread. Preferences is threadsafe so it should work regardless.

Upvotes: 0

Related Questions