转载请注明出处:http://blog.csdn.net/droyon/article/details/35558611
SqlArguments
/**
* Decode a content URL into the table, projection, and arguments
* used to access the corresponding database rows.
*/
包装请求的ContentUri,插入的数据表、projection,where cause等。
1、限定请求的url地址
if (url.getPathSegments().size() == 1) {
// of the form content://settings/secure, arbitrary where clause
2、必须为content://settings/secure/brightness,包含两级pathSegmentselse if (url.getPathSegments().size() != 2) { throw new IllegalArgumentException("Invalid URI: " + url);
// of the form content://settings/secure, arbitrary where clause
2、必须为content://settings/secure/brightness,包含两级pathSegmentselse if (url.getPathSegments().size() != 2) { throw new IllegalArgumentException("Invalid URI: " + url);
SqlArguments(Uri url, String where, String[] args) {
if (url.getPathSegments().size() == 1) {
// of the form content://settings/secure, arbitrary where clause
this.table = url.getPathSegments().get(0);
if (!DatabaseHelper.isValidTable(this.table)) {
throw new IllegalArgumentException("Bad root path: " + this.table);
}
this.where = where;
this.args = args;
} else if (url.getPathSegments().size() != 2) {
throw new IllegalArgumentException("Invalid URI: " + url);
} else if (!TextUtils.isEmpty(where)) {
throw new UnsupportedOperationException("WHERE clause not supported: " + url);
} else {
// of the form content://settings/secure/element_name, no where clause
this.table = url.getPathSegments().get(0);
if (!DatabaseHelper.isValidTable(this.table)) {
throw new IllegalArgumentException("Bad root path: " + this.table);
}
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table) ||
TABLE_GLOBAL.equals(this.table)) {
this.where = Settings.NameValueTable.NAME + "=?";
final String name = url.getPathSegments().get(1);
this.args = new String[] { name };
// Rewrite the table for known-migrated names
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table)) {
if (sSecureGlobalKeys.contains(name) || sSystemGlobalKeys.contains(name)) {
this.table = TABLE_GLOBAL;
}
}
} else {
// of the form content://bookmarks/19
this.where = "_id=" + ContentUris.parseId(url);
this.args = null;
}
}
}
3、where必须为empty
else if (!TextUtils.isEmpty(where)) {
throw new UnsupportedOperationException("WHERE clause not supported: " + url);
}
throw new UnsupportedOperationException("WHERE clause not supported: " + url);
}
4、
this.table = url.getPathSegments().get(0);
if (!DatabaseHelper.isValidTable(this.table)) {
throw new IllegalArgumentException("Bad root path: " + this.table);
}
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table) ||
TABLE_GLOBAL.equals(this.table)) {
this.where = Settings.NameValueTable.NAME + "=?";
final String name = url.getPathSegments().get(1);
this.args = new String[] { name };
// Rewrite the table for known-migrated names
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table)) {
if (sSecureGlobalKeys.contains(name) || sSystemGlobalKeys.contains(name)) { //更改table名
this.table = TABLE_GLOBAL;
}
}
} else {
// of the form content://bookmarks/19
this.where = "_id=" + ContentUris.parseId(url);
this.args = null;
}
if (!DatabaseHelper.isValidTable(this.table)) {
throw new IllegalArgumentException("Bad root path: " + this.table);
}
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table) ||
TABLE_GLOBAL.equals(this.table)) {
this.where = Settings.NameValueTable.NAME + "=?";
final String name = url.getPathSegments().get(1);
this.args = new String[] { name };
// Rewrite the table for known-migrated names
if (TABLE_SYSTEM.equals(this.table) || TABLE_SECURE.equals(this.table)) {
if (sSecureGlobalKeys.contains(name) || sSystemGlobalKeys.contains(name)) { //更改table名
this.table = TABLE_GLOBAL;
}
}
} else {
// of the form content://bookmarks/19
this.where = "_id=" + ContentUris.parseId(url);
this.args = null;
}