getContentResolver().query 和 managedQuery 的区别

来源:互联网 发布:网络灯谜精选汇总 编辑:程序博客网 时间:2024/05/20 18:01

 managedQuery ——》android.app.Activity.managedQuery

query ——》android.content.ContentResolver.query

To query a content provider, you can use either the ContentResolver.query() method or the Activity.managedQuery() method. Both methods take the same set of arguments, and both return a Cursor object. However, managedQuery() causes the activity to manage the life cycle of the Cursor. A managed Cursor handles all of the niceties, such as unloading itself when the activity pauses, and requerying itself when the activity restarts. You can ask an Activity to begin managing an unmanaged Cursor object for you by calling Activity.startManagingCursor().


重点这句: However, managedQuery() causes the activity to manage the life cycle of the Cursor. 产生的游标的生命周期和当前activity关联,activity销毁,Cursor销毁...