通过Uri查询数据得到Cursor

1、通过Uri可以对数据进行查询,返回一个包含特定数据(结果集)的Cursor对象(Cursor提供了遍历查询结果的方法),主要有两种方式:

1.1 Activity.managedQuery()方法(目前被废弃)

根据指定的URI路径信息返回包含特定数据的Cursor对象,应用这个方法可以使Activity接管返回数据对象的生命周期。
参数分析:
URI:  Content Provider 需要返回的资源索引
Projection: 用于标识有哪些columns需要包含在返回数据中。
Selection: 作为查询符合条件的过滤参数,类似于SQL语句中Where之后的条件判断。
SelectionArgs: 同上。
SortOrder: 用于对返回信息进行排序


1.2 getContentResolver.query()

参数和managedQuery相同。





参考资料:http://blog.sina.com.cn/s/blog_5f436e6501012rdw.html

http://blog.csdn.net/quaful/article/details/6976768(有关Activity接管Cursor生命周期的讨论)

http://blog.csdn.net/lccly/article/details/6893943


你可能感兴趣的:(Android)