Code example for Uri

Methods: getPathSegments, withAppendedId, withAppendedPath

0
            } 
        } 
 
        /** Insert new rows (no where clause allowed). */ 
        SqlArguments(Uri url) {
            if (url.getPathSegments().size() == 1) {
                this.table = url.getPathSegments().get(0);
                this.where = null;
                this.args = null;
            } else { 
                throw new IllegalArgumentException("Invalid URI: " + url);
            } 
        } 
    } 
 
    /** 
     * Get the content URI of a row added to a table. 
     * @param tableUri of the entire table 
     * @param values found in the row 
     * @param rowId of the row 
     * @return the content URI for this particular row 
     */ 
    private Uri getUriFor(Uri tableUri, ContentValues values, long rowId) {
        if (tableUri.getPathSegments().size() != 1) {
            throw new IllegalArgumentException("Invalid URI: " + tableUri);
        } 
        String table = tableUri.getPathSegments().get(0);
        if ("gservices".equals(table) || "system".equals(table)
                || "secure".equals(table)) {
            String name = values.getAsString(Settings.NameValueTable.NAME);
            return Uri.withAppendedPath(tableUri, name);
        } else { 
            return ContentUris.withAppendedId(tableUri, rowId);
        } 
    } 
 
    /** 
     * Send a notification when a particular content URI changes.