Android 中的 ManagedQuery()

用途:

根据指定的URI路径信息返回包含特定数据的Cursor对象,应用这个方法可以使Activity接管返回数据对象的生命周期。

参数:

URI:  Content Provider 需要返回的资源索引

Projection: 用于标识有哪些columns需要包含在返回数据中。

Selection: 作为查询符合条件的过滤参数,类似于SQL语句中Where之后的条件判断。

SelectionArgs: 同上。

SortOrder: 用于对返回信息进行排序。

下面是有关 ContentResolver.query() 和 Activity.managedQuery() 两个方法的区别:

  To query a content provider, you can use either theContentResolver.query() method or the Activity.managedQuery() method.Both methods take the same set of arguments, and both return a Cursorobject. However, managedQuery() causes the activity to manage the lifecycle of the Cursor. [...]

我也来翻译下:

 对于查询一个内容提供者,你可以使用 ContentResolver.query() 或者 Activity.managedQuery() 方法。两种方法都带有相同参数,并且都返回 Cursor 对象。然后,Activity.managedQuery()  方法导致活动管理 Cursor 的生命周期。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值