Example usage for org.apache.cordova CordovaResourceApi copyResource

List of usage examples for org.apache.cordova CordovaResourceApi copyResource

Introduction

In this page you can find the example usage for org.apache.cordova CordovaResourceApi copyResource.

Prototype

public void copyResource(Uri sourceUri, Uri dstUri) throws IOException 

Source Link

Usage

From source file:org.chromium.ChromeStorage.java

License:Open Source License

private JSONObject getStorage(String namespace) throws IOException, JSONException {
    JSONObject oldMap = new JSONObject();
    CordovaResourceApi resourceApi = webView.getResourceApi();
    try {/*  w ww .  j  a va2 s . c o m*/
        OpenForReadResult readResult = resourceApi.openForRead(getStorageFile(namespace));
        ByteArrayOutputStream readBytes = new ByteArrayOutputStream((int) readResult.length);
        resourceApi.copyResource(readResult, readBytes);
        byte[] bytes = readBytes.toByteArray();
        String content = (new String(bytes)).trim();
        if (content.length() > 0) {
            oldMap = new JSONObject(content);
        }
    } catch (FileNotFoundException e) {
        //Suppress the file not found exception
    }
    return oldMap;
}