apla / me.apla.cordova.app-preferences

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

Android no value for key #5

Closed gazever closed 9 years ago

gazever commented 10 years ago

Hi this behaves differently on Android to iOS.

On iOS if there is no value when fetching a key null is returned to the success callback, on android the errorCallback is called

line 145 : if (sharedPrefs.contains(key)) { ....

line 177 : } else { // Log.d("", "no value"); callbackContext.error(0); // callbackContext.sendPluginResult(new PluginResult ()); }

To rectify and fit my needs I changed this in the else line 177 : } else { // Log.d("", "no value"); callbackContext.success(returnVal); }

as returnVal is declared as null on line 144.

In my personal opinion I think its better for them both to return null to the success callback rather than the call the error callback

apla commented 10 years ago

ok, can you send me a pull request?

apla commented 9 years ago

fixed with ff52c73503331a90fe34e0b62fc7498bfe2f23f6