Code example for Uri

Methods: getPathSegments, getQueryParameter

0
        } 
    } 
 
    private static String getClientId(final Uri uri) {
        int protocolVersion = 1;
        final String protocolVersionArg = uri.getQueryParameter(QUERY_PARAMETER_PROTOCOL_VERSION);
        if ("2".equals(protocolVersionArg)) protocolVersion = 2;
        switch (protocolVersion) {
            case 1: return null; // In protocol 1, the client ID is always null. 
            case 2: return uri.getPathSegments().get(0);
            default: return null; 
        } 
    } 
 
    /** 
     * Returns the MIME type of the content associated with an Uri 
     * 
     * @see android.content.ContentProvider#getType(android.net.Uri) 
     * 
     * @param uri the URI of the content the type of which should be returned. 
     * @return the MIME type, or null if the URL is not recognized.