错误示范:
Uri rowuri = Uri.parse("content://" + 某表URI+ msgId);
ContentValues values = new ContentValues();
String where = "name <> ?";
values.put("age", "20");
contentResolver.update(rowuri, values, where, new String[] { "yang"});
对指定rowuri 的数据进行update,如果name属性不是yang的,那么age属性就改成20。
其实这是不起作用的,具体原因没有找到,但是我猜测跟指定了rowuri有关,换个写法就OK了。
正确示范:
ContentValues values = new ContentValues();
values.put("age", "20");
String where = "msgId = ? and name <> ?";
contentResolver.update(某表URI, values, where, new String[] { String.valueOf(msgId),
"yang" });
如果哪位牛人知道为什么上面方法不成功,请告知。多谢。