在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常用方法

本文介绍了Android系统中ContentResolver的作用及使用方法。通过示例代码展示了如何利用ContentResolver查询应用程序暴露的数据,包括创建Uri、获取ContentResolver实例、执行查询操作等步骤。
1063

被折叠的 条评论
为什么被折叠?



