Android 数据存储之 ContentProvider
2010-03-03 16:44:00 来源:WEB开发网null, sortOrder);
default:
throw new IllegalArgumentException("Uri IllegalArgument:" + uri);
}
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
SQLiteDatabase db = this.openHelper.getWritableDatabase();
int result;
switch (uriMatcher.match(uri)) {
case CONTACT_LIST:
result = db.update(selection, values, selection, selectionArgs);
break;
case CONTACT:
long id = ContentUris.parseId(uri);
String where = "_id=" + id;
if (selection != null && !"".equals(selection)) {
where = where + " and " + selection;
}
result = db.update(tableName, values, where, selectionArgs);
break;
default:
throw new IllegalArgumentException("Uri IllegalArgument:" + uri);
}
return result;
}
}
2.添加ContentProvider配置
<provider android:name=".provider.ContactContentProvider" android:authorities="com.changcheng.sqlite.provider.contactprovider"/> |
更多精彩
赞助商链接