Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / cordova-read-config-vipera   js

Repository URL to install this package:

Version: 0.0.1 

/ src / android / CordovaReadConfig.java

package com.vipera.CordovaReadConfig;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaPreferences;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class CordovaReadConfig extends CordovaPlugin
{
    private static final String READ_CONFIG = "readConfig";

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
    {
        if (action.equals(READ_CONFIG))
        {
            try
            {
                CordovaPreferences preferences = webView.getPreferences();
                JSONObject result = new JSONObject(preferences.getAll());
                callbackContext.success(result);
            }
            catch (Exception e)
            {
                callbackContext.error(e.getMessage());
            }

            return true;
        }

        return false;
    }
}