Example usage for org.json JSONArray getBoolean

List of usage examples for org.json JSONArray getBoolean

Introduction

In this page you can find the example usage for org.json JSONArray getBoolean.

Prototype

public boolean getBoolean(int index) throws JSONException 

Source Link

Document

Get the boolean value associated with an index.

Usage

From source file:com.qbcps.sifterclient.SifterReader.java

private String getFilterSlug() {
    String projDetailURL;//from w w w . j a v a  2  s  .  co m
    int issuesPerPage;
    JSONArray status;
    JSONArray priority;
    int numStatuses;
    int numPriorities;
    boolean[] filterStatus;
    boolean[] filterPriority;
    try {
        JSONObject filters = mSifterHelper.getFiltersFile();
        if (filters.length() == 0)
            return "";
        issuesPerPage = filters.getInt(IssuesActivity.PER_PAGE);
        status = filters.getJSONArray(IssuesActivity.STATUS);
        priority = filters.getJSONArray(IssuesActivity.PRIORITY);
        numStatuses = status.length();
        numPriorities = priority.length();
        filterStatus = new boolean[numStatuses];
        filterPriority = new boolean[numPriorities];
        for (int i = 0; i < numStatuses; i++)
            filterStatus[i] = status.getBoolean(i);
        for (int i = 0; i < numPriorities; i++)
            filterPriority[i] = priority.getBoolean(i);
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return "";
    }
    projDetailURL = "?" + IssuesActivity.PER_PAGE + "=" + issuesPerPage;
    projDetailURL += "&" + IssuesActivity.GOTO_PAGE + "=1";
    JSONObject statuses;
    JSONObject priorities;
    JSONArray statusNames;
    JSONArray priorityNames;
    try {
        JSONObject sifterJSONObject = mSifterHelper.getSifterFilters();
        statuses = sifterJSONObject.getJSONObject(IssuesActivity.STATUSES);
        priorities = sifterJSONObject.getJSONObject(IssuesActivity.PRIORITIES);
        statusNames = statuses.names();
        priorityNames = priorities.names();
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return "";
    }
    try {
        String filterSlug = "&s=";
        for (int i = 0; i < numStatuses; i++) {
            if (filterStatus[i])
                filterSlug += String.valueOf(statuses.getInt(statusNames.getString(i))) + "-";
        }
        if (filterSlug.length() > 3) {
            filterSlug = filterSlug.substring(0, filterSlug.length() - 1);
            projDetailURL += filterSlug;
        }
        filterSlug = "&p=";
        for (int i = 0; i < numPriorities; i++) {
            if (filterPriority[i])
                filterSlug += String.valueOf(priorities.getInt(priorityNames.getString(i))) + "-";
        }
        if (filterSlug.length() > 3) {
            filterSlug = filterSlug.substring(0, filterSlug.length() - 1);
            projDetailURL += filterSlug;
        }
    } catch (JSONException e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return "";
    }
    return projDetailURL;
}

From source file:com.polychrom.cordova.ActionBarPlugin.java

@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext)
        throws JSONException {
    if (!plugin_actions.contains(action)) {
        return false;
    }//from   ww  w.j av  a  2  s.co  m

    final Activity ctx = (Activity) cordova;

    if ("isAvailable".equals(action)) {
        JSONObject result = new JSONObject();
        result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR));
        callbackContext.success(result);
        return true;
    }

    final ActionBar bar = ctx.getActionBar();
    if (bar == null) {
        Window window = ctx.getWindow();
        if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) {
            callbackContext
                    .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!");
        } else {
            callbackContext.error("Failed to get ActionBar");
        }

        return true;
    }

    if (menu == null) {
        callbackContext.error("Options menu not initialised");
        return true;
    }

    final StringBuffer error = new StringBuffer();
    JSONObject result = new JSONObject();

    if ("isShowing".equals(action)) {
        result.put("value", bar.isShowing());
    } else if ("getHeight".equals(action)) {
        result.put("value", bar.getHeight());
    } else if ("getDisplayOptions".equals(action)) {
        result.put("value", bar.getDisplayOptions());
    } else if ("getNavigationMode".equals(action)) {
        result.put("value", bar.getNavigationMode());
    } else if ("getSelectedNavigationItem".equals(action)) {
        result.put("value", bar.getSelectedNavigationIndex());
    } else if ("getSubtitle".equals(action)) {
        result.put("value", bar.getSubtitle());
    } else if ("getTitle".equals(action)) {
        result.put("value", bar.getTitle());
    } else {
        try {
            JSONException exception = new Runnable() {
                public JSONException exception = null;

                public void run() {
                    try {
                        // This is a bit of a hack (should be specific to the request, not global)
                        bases = new String[] { removeFilename(webView.getOriginalUrl()),
                                removeFilename(webView.getUrl()) };

                        if ("show".equals(action)) {
                            bar.show();
                        } else if ("hide".equals(action)) {
                            bar.hide();
                        } else if ("setMenu".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            menu_definition = args.getJSONArray(0);

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                                ctx.invalidateOptionsMenu();
                            }
                        } else if ("setTabs".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("menu can not be null");
                                return;
                            }

                            bar.removeAllTabs();
                            tab_callbacks.clear();

                            if (!buildTabs(bar, args.getJSONArray(0))) {
                                error.append("Invalid tab bar definition");
                            }
                        } else if ("setDisplayHomeAsUpEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHomeAsUp can not be null");
                                return;
                            }

                            bar.setDisplayHomeAsUpEnabled(args.getBoolean(0));
                        } else if ("setDisplayOptions".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("options can not be null");
                                return;
                            }

                            final int options = args.getInt(0);
                            bar.setDisplayOptions(options);
                        } else if ("setDisplayShowHomeEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showHome can not be null");
                                return;
                            }

                            bar.setDisplayShowHomeEnabled(args.getBoolean(0));
                        } else if ("setDisplayShowTitleEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("showTitle can not be null");
                                return;
                            }

                            bar.setDisplayShowTitleEnabled(args.getBoolean(0));
                        } else if ("setDisplayUseLogoEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("useLogo can not be null");
                                return;
                            }

                            bar.setDisplayUseLogoEnabled(args.getBoolean(0));
                        } else if ("setHomeButtonEnabled".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("enabled can not be null");
                                return;
                            }

                            bar.setHomeButtonEnabled(args.getBoolean(0));
                        } else if ("setIcon".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("icon can not be null");
                                return;
                            }

                            Drawable drawable = getDrawableForURI(args.getString(0));
                            bar.setIcon(drawable);
                        } else if ("setListNavigation".equals(action)) {
                            JSONArray items = null;
                            if (args.isNull(0) == false) {
                                items = args.getJSONArray(0);
                            }

                            navigation_adapter.setItems(items);
                            bar.setListNavigationCallbacks(navigation_adapter, navigation_listener);
                        } else if ("setLogo".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("logo can not be null");
                                return;
                            }

                            Drawable drawable = getDrawableForURI(args.getString(0));
                            bar.setLogo(drawable);
                        } else if ("setNavigationMode".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("mode can not be null");
                                return;
                            }

                            final int mode = args.getInt(0);
                            bar.setNavigationMode(mode);
                        } else if ("setSelectedNavigationItem".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("position can not be null");
                                return;
                            }

                            bar.setSelectedNavigationItem(args.getInt(0));
                        } else if ("setSubtitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("subtitle can not be null");
                                return;
                            }

                            bar.setSubtitle(args.getString(0));
                        } else if ("setTitle".equals(action)) {
                            if (args.isNull(0)) {
                                error.append("title can not be null");
                                return;
                            }

                            bar.setTitle(args.getString(0));
                        }
                    } catch (JSONException e) {
                        exception = e;
                    } finally {
                        synchronized (this) {
                            this.notify();
                        }
                    }
                }

                // Run task synchronously
                {
                    synchronized (this) {
                        ctx.runOnUiThread(this);
                        this.wait();
                    }
                }
            }.exception;

            if (exception != null) {
                throw exception;
            }
        } catch (InterruptedException e) {
            error.append("Function interrupted on UI thread");
        }
    }

    if (error.length() == 0) {
        if (result.length() > 0) {
            callbackContext.success(result);
        } else {
            callbackContext.success();
        }
    } else {
        callbackContext.error(error.toString());
    }

    return true;
}

From source file:com.connectsdk.cordova.ConnectSDKCordova.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    try {/*from  w  ww .  j  av  a 2 s . c om*/

        if ("sendCommand".equals(action)) {
            ConnectableDeviceWrapper deviceWrapper = getDeviceWrapper(args.getString(0));

            String commandId = args.getString(1);
            String ifaceName = args.getString(2);
            String methodName = args.getString(3);
            JSONObject methodArgs = args.getJSONObject(4);
            boolean subscribe = args.getBoolean(5);
            deviceWrapper.sendCommand(commandId, ifaceName, methodName, methodArgs, subscribe, callbackContext);
            return true;
        } else if ("cancelCommand".equals(action)) {
            ConnectableDeviceWrapper deviceWrapper = getDeviceWrapper(args.getString(0));
            String commandId = args.getString(1);

            deviceWrapper.cancelCommand(commandId);
            callbackContext.success();

            return true;
        } else if ("startDiscovery".equals(action)) {
            startDiscovery(args, callbackContext);
            return true;
        } else if ("stopDiscovery".equals(action)) {
            stopDiscovery(args, callbackContext);
            return true;
        } else if ("setDiscoveryConfig".equals(action)) {
            setDiscoveryConfig(args, callbackContext);
            return true;
        } else if ("pickDevice".equals(action)) {
            pickDevice(args, callbackContext);
            return true;
        } else if ("setDeviceListener".equals(action)) {
            ConnectableDeviceWrapper deviceWrapper = getDeviceWrapper(args.getString(0));
            deviceWrapper.setCallbackContext(callbackContext);
            return true;
        } else if ("connectDevice".equals(action)) {
            ConnectableDeviceWrapper deviceWrapper = getDeviceWrapper(args.getString(0));
            deviceWrapper.setCallbackContext(callbackContext);
            deviceWrapper.connect();
            return true;
        } else if ("disconnectDevice".equals(action)) {
            ConnectableDeviceWrapper deviceWrapper = getDeviceWrapper(args.getString(0));
            deviceWrapper.disconnect();
            return true;
        } else if ("acquireWrappedObject".equals(action)) {
            String objectId = args.getString(0);
            JSObjectWrapper wrapper = objectWrappers.get(objectId);

            if (wrapper != null) {
                wrapper.setCallbackContext(callbackContext);
            }

            return true;
        } else if ("releaseWrappedObject".equals(action)) {
            String objectId = args.getString(0);
            JSObjectWrapper wrapper = objectWrappers.get(objectId);

            if (wrapper != null) {
                wrapper.setCallbackContext(null);
                removeObjectWrapper(wrapper);
            }

            return true;
        }
    } catch (NoSuchDeviceException e) {
        callbackContext.error("no such device");
        return true;
    } catch (JSONException e) {
        Log.d(LOG_TAG, "exception while handling " + action, e);
        callbackContext.error(e.toString());
        return true;
    }

    Log.w(LOG_TAG, "no handler for exec action " + action);
    return false;
}

From source file:com.adobe.phonegap.contentsync.Sync.java

private void sync(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    // get args/* www. j a  v  a  2s.  com*/
    final String src = args.getString(0);
    final String id = args.getString(1);
    final JSONObject headers;
    if (args.optJSONObject(3) != null) {
        headers = args.optJSONObject(3);
    } else {
        headers = new JSONObject();
    }
    final boolean copyCordovaAssets;
    final boolean copyRootApp = args.getBoolean(5);
    final boolean trustEveryone = args.getBoolean(7);
    if (copyRootApp) {
        copyCordovaAssets = true;
    } else {
        copyCordovaAssets = args.getBoolean(4);
    }
    final String manifestFile = args.getString(8);
    Log.d(LOG_TAG, "sync called with id = " + id + " and src = " + src + "!");

    final ProgressEvent progress = createProgressEvent(id);

    /**
     * need to clear cache or Android won't pick up on the replaced
     * content
     */
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            webView.clearCache(true);
        }
    });

    cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            synchronized (progress) {
                if (progress.isAborted()) {
                    return;
                }
            }

            String outputDirectory = getOutputDirectory(id);

            // Check to see if we should just return the cached version
            String type = args.optString(2, TYPE_REPLACE);
            Log.d(LOG_TAG, "type = " + type);
            File dir = new File(outputDirectory);
            Log.d(LOG_TAG, "dir = " + dir.exists());

            if (type.equals(TYPE_LOCAL) && !dir.exists()) {
                if ("null".equals(src) && (copyRootApp || copyCordovaAssets)) {
                    if (copyRootApp) {
                        copyRootApp(outputDirectory, manifestFile);
                    }
                    if (copyCordovaAssets) {
                        copyCordovaAssets(outputDirectory);
                    }

                } else {
                    type = TYPE_REPLACE;
                }
            }

            if (!dir.exists()) {
                dir.mkdirs();
            }

            if (!type.equals(TYPE_LOCAL)) {
                // download file
                if (download(src, createDownloadFileLocation(id), headers, progress, callbackContext,
                        trustEveryone)) {
                    // update progress with zip file
                    File targetFile = progress.getTargetFile();
                    Log.d(LOG_TAG, "downloaded = " + targetFile.getAbsolutePath());

                    // Backup existing directory
                    File backup = backupExistingDirectory(outputDirectory, type, dir);

                    // @TODO: Do we do this even when type is local?
                    if (copyRootApp) {
                        copyRootApp(outputDirectory, manifestFile);
                    }

                    boolean win = false;
                    if (isZipFile(targetFile)) {
                        win = unzipSync(targetFile, outputDirectory, progress, callbackContext);
                    } else {
                        // copy file to ID
                        win = targetFile.renameTo(new File(outputDirectory));
                        progress.setLoaded(1);
                        progress.setTotal(1);
                        progress.setStatus(STATUS_EXTRACTING);
                        progress.updatePercentage();
                    }

                    // delete temp file
                    targetFile.delete();

                    if (copyCordovaAssets) {
                        copyCordovaAssets(outputDirectory);
                    }

                    if (win) {
                        // success, remove backup
                        removeFolder(backup);
                    } else {
                        // failure, revert backup
                        removeFolder(dir);
                        backup.renameTo(dir);
                    }
                } else {
                    return;
                }
            }

            // complete
            synchronized (activeRequests) {
                activeRequests.remove(id);
            }

            // Send last progress event
            progress.setStatus(STATUS_COMPLETE);
            updateProgress(callbackContext, progress);

            // Send completion message
            try {
                JSONObject result = new JSONObject();
                result.put(PROP_LOCAL_PATH, outputDirectory);
                result.put(PROP_CACHED, type.equals(TYPE_LOCAL));
                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
            } catch (JSONException e) {
                // never happens
            }
        }
    });
}

From source file:com.liferay.mobile.android.v62.user.UserService.java

public Boolean hasGroupUser(long groupId, long userId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  w w w .  j a v  a  2s. com*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);

        _command.put("/user/has-group-user", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getBoolean(0);
}

From source file:com.liferay.mobile.android.v62.user.UserService.java

public Boolean hasRoleUser(long roleId, long userId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*  www.j av a 2  s .  c  o m*/
        JSONObject _params = new JSONObject();

        _params.put("roleId", roleId);
        _params.put("userId", userId);

        _command.put("/user/has-role-user", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getBoolean(0);
}

From source file:com.liferay.mobile.android.v62.user.UserService.java

public Boolean hasRoleUser(long companyId, String name, long userId, boolean inherited) throws Exception {
    JSONObject _command = new JSONObject();

    try {//  www  .j a  va2s. co m
        JSONObject _params = new JSONObject();

        _params.put("companyId", companyId);
        _params.put("name", checkNull(name));
        _params.put("userId", userId);
        _params.put("inherited", inherited);

        _command.put("/user/has-role-user", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getBoolean(0);
}

From source file:com.BreakingBytes.SifterReader.SifterReader.java

private String getFilterSlug() {
    String projDetailURL = new String();
    int issuesPerPage = IssuesActivity.MAX_PER_PAGE;
    JSONArray status = new JSONArray();
    JSONArray priority = new JSONArray();
    int numStatuses;
    int numPriorities;
    boolean[] filterStatus;
    boolean[] filterPriority;
    try {/*  www .jav  a  2  s . c om*/
        JSONObject filters = mSifterHelper.getFiltersFile();
        if (filters.length() == 0)
            return new String();
        issuesPerPage = filters.getInt(IssuesActivity.PER_PAGE);
        status = filters.getJSONArray(IssuesActivity.STATUS);
        priority = filters.getJSONArray(IssuesActivity.PRIORITY);
        numStatuses = status.length();
        numPriorities = priority.length();
        filterStatus = new boolean[numStatuses];
        filterPriority = new boolean[numPriorities];
        for (int i = 0; i < numStatuses; i++)
            filterStatus[i] = status.getBoolean(i);
        for (int i = 0; i < numPriorities; i++)
            filterPriority[i] = priority.getBoolean(i);
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return new String();
    }
    projDetailURL = "?" + IssuesActivity.PER_PAGE + "=" + issuesPerPage;
    projDetailURL += "&" + IssuesActivity.GOTO_PAGE + "=1";
    JSONObject statuses = new JSONObject();
    JSONObject priorities = new JSONObject();
    JSONArray statusNames = new JSONArray();
    JSONArray priorityNames = new JSONArray();
    try {
        JSONObject sifterJSONObject = mSifterHelper.getSifterFilters();
        statuses = sifterJSONObject.getJSONObject(IssuesActivity.STATUSES);
        priorities = sifterJSONObject.getJSONObject(IssuesActivity.PRIORITIES);
        statusNames = statuses.names();
        priorityNames = priorities.names();
    } catch (Exception e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return new String();
    }
    try {
        String filterSlug = "&s=";
        for (int i = 0; i < numStatuses; i++) {
            if (filterStatus[i])
                filterSlug += String.valueOf(statuses.getInt(statusNames.getString(i))) + "-";
        }
        if (filterSlug.length() > 3) {
            filterSlug = filterSlug.substring(0, filterSlug.length() - 1);
            projDetailURL += filterSlug;
        }
        filterSlug = "&p=";
        for (int i = 0; i < numPriorities; i++) {
            if (filterPriority[i])
                filterSlug += String.valueOf(priorities.getInt(priorityNames.getString(i))) + "-";
        }
        if (filterSlug.length() > 3) {
            filterSlug = filterSlug.substring(0, filterSlug.length() - 1);
            projDetailURL += filterSlug;
        }
    } catch (JSONException e) {
        e.printStackTrace();
        mSifterHelper.onException(e.toString());
        return new String();
    }
    return projDetailURL;
}

From source file:de.martinreinhardt.cordova.plugins.CertificatesPlugin.java

/**
 * Executes the request.// www .j av a2s.c  o  m
 *
 * This method is called from the WebView thread. To do a non-trivial amount
 * of work, use: cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 * cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action
 *            The action to execute. (Currently "setUntrusted only")
 * @param args
 *            The exec() arguments.
 * @param callbackContext
 *            The callback context used when calling back into JavaScript.
 * @return Whether the action was valid.
 *
 *
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    if (action.equals("setUntrusted")) {
        try {
            allowUntrusted = args.getBoolean(0);
            Log.d(LOG_TAG, "Setting allowUntrusted to " + allowUntrusted);
            cordova.getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    try {
                        CordovaActivity ca = (CordovaActivity) cordova.getActivity();
                        SystemWebView view = (SystemWebView) webView.getView();
                        CertificatesCordovaWebViewClient cWebClient = new CertificatesCordovaWebViewClient(
                                (SystemWebViewEngine) webView.getEngine());

                        cWebClient.setAllowUntrusted(allowUntrusted);
                        webView.clearCache();
                        view.setWebViewClient(cWebClient);
                    } catch (Exception e) {
                        Log.e(LOG_TAG, "Got unkown error during setting webview in activity", e);
                    }
                }
            });
            callbackContext.success();
            return true;
        } catch (Exception e) {
            Log.e(LOG_TAG, "Got unkown error during passing to UI Thread", e);
        }
    }
    callbackContext.error("Invalid Command");
    return false;
}

From source file:com.phonegap.FileUtils.java

/**
 * Executes the request and returns PluginResult.
 * //w  w w . j  a  va  2 s.  com
 * @param action       The action to execute.
 * @param args          JSONArry of arguments for the plugin.
 * @param callbackId   The callback id used when calling back into JavaScript.
 * @return             A PluginResult object with a status and message.
 */
public PluginResult execute(String action, JSONArray args, String callbackId) {
    PluginResult.Status status = PluginResult.Status.OK;
    String result = "";
    //System.out.println("FileUtils.execute("+action+")");

    try {
        if (action.equals("testSaveLocationExists")) {
            boolean b = DirectoryManager.testSaveLocationExists();
            return new PluginResult(status, b);
        } else if (action.equals("getFreeDiskSpace")) {
            long l = DirectoryManager.getFreeDiskSpace();
            return new PluginResult(status, l);
        } else if (action.equals("testFileExists")) {
            boolean b = DirectoryManager.testFileExists(args.getString(0));
            return new PluginResult(status, b);
        } else if (action.equals("testDirectoryExists")) {
            boolean b = DirectoryManager.testFileExists(args.getString(0));
            return new PluginResult(status, b);
        } else if (action.equals("deleteDirectory")) {
            boolean b = DirectoryManager.deleteDirectory(args.getString(0));
            return new PluginResult(status, b);
        } else if (action.equals("deleteFile")) {
            boolean b = DirectoryManager.deleteFile(args.getString(0));
            return new PluginResult(status, b);
        } else if (action.equals("createDirectory")) {
            boolean b = DirectoryManager.createDirectory(args.getString(0));
            return new PluginResult(status, b);
        } else if (action.equals("getRootPaths")) {
            return new PluginResult(status, DirectoryManager.getRootPaths());
        } else if (action.equals("readAsText")) {
            try {
                String s = this.readAsText(args.getString(0), args.getString(1));
                return new PluginResult(status, s);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR);
            } catch (IOException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_READABLE_ERR);
            }
        } else if (action.equals("readAsDataURL")) {
            try {
                String s = this.readAsDataURL(args.getString(0));
                return new PluginResult(status, s);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR);
            } catch (IOException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_READABLE_ERR);
            }
        } else if (action.equals("writeAsText")) {
            try {
                this.writeAsText(args.getString(0), args.getString(1), args.getBoolean(2));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR);
            } catch (IOException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_READABLE_ERR);
            }
        } else if (action.equals("write")) {
            try {
                long fileSize = this.write(args.getString(0), args.getString(1), args.getLong(2));
                return new PluginResult(status, fileSize);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR);
            } catch (IOException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_READABLE_ERR);
            }
        } else if (action.equals("truncate")) {
            try {
                long fileSize = this.truncateFile(args.getString(0), args.getLong(1));
                return new PluginResult(status, fileSize);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR);
            } catch (IOException e) {
                e.printStackTrace();
                return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_READABLE_ERR);
            }
        } else if (action.equals("getFile")) {
            JSONObject obj = DirectoryManager.getFile(args.getString(0));
            return new PluginResult(status, obj);
        }
        return new PluginResult(status, result);
    } catch (JSONException e) {
        e.printStackTrace();
        return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
    }
}