apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 209 forks source link

Preferences not accessable from java. #42

Closed ksabariraj closed 9 years ago

ksabariraj commented 9 years ago

Hi, Thanks for the plugin.

I set preference and I can able to read using plugin. But, when I tried to access the same preferences from Java code, its not available. Can you please guide me on this.

apla commented 9 years ago

Are you using

SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(cordova.getActivity());

to get the shared preferences? If yes, please give me snippet of code which confirms the issue.

ksabariraj commented 9 years ago

Hey,

Sorry for the delay response.

Please see the below code. ( I used same as in SplashScreen.java ) preferences.getInteger("UserID", 0);

When I tried to print the application preference, I got only the preference which I mention in config file.

Thanks, Sabari.

ksabariraj commented 9 years ago

Hey,

Its working after creating sharedPref object as you mentioned.

SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(cordova.getActivity());

Thanks, Sabari.