在Android系统中,ContentResolver充当着桥梁的角色。应用程序通过ContentProvider暴露自己的数据,通过ContentResolver对应用程序暴露的数据进行操作。
- 通过ContentResovler对象实现数据的操作代码如下:
Uri uri=Uri.parse(“content://cn.itcast.db.personprovider/person”);
ContentResolver resolver=context.getContentResolver();
Cursor cursor = resolver . query ( un , new String ( " address " , " date " , " type " , " body " ) , null , null , null )
while(cursor.moveToNext()){
String address=cursor.getString(0);
…
}
cursor.close():
contentobserver常用方法