src/android/Serializer.java
/** Convert an Uri to JSON object.
     *
     * Object will include:
     *    "type" of data;
     *    "uri" itself;
     *    "path" to the file, if applicable.
     *    "data" for the file.
     */
Convert an Uri to JSON object.
Convert an Uri to JSON object .
public static JSONObject toJSONObject(
            final ContentResolver contentResolver,
            final Uri uri)
            throws JSONException {
        if (uri == null) {
            return null;
        }
        final JSONObject json = new JSONObject();
        final String type = contentResolver.getType(uri);
        json.put("type", type);
        json.put("isVideo", type.startsWith("video/"));
        json.put("uri", uri);
        final ArrayMap<String, String> realData = getRealDataFromURI(contentResolver, type, uri);
        for (ArrayMap.Entry<String, String> entry : realData.entrySet()) {
            json.put(entry.getKey(), entry.getValue());
        }
        return json;
    }
public static JSONObject toJSONObject ( final ContentResolver contentResolver , final Uri uri ) throws JSONException { if ( uri == null ) { return null ; } final JSONObject json = new JSONObject ( ) ; final String type = contentResolver . getType ( uri ) ; json . put ( "type" , type ) ; json . put ( "isVideo" , type . startsWith ( "video/" ) ) ; json . put ( "uri" , uri ) ; final ArrayMap < String , String > realData = getRealDataFromURI ( contentResolver , type , uri ) ; for ( ArrayMap . Entry < String , String > entry : realData . entrySet ( ) ) { json . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } return json ; }
Convert an Uri to JSON object.
Convert an Uri to JSON object .