The method managedQuery(Uri, String[], String, String[], String) from the type Activity is deprecated

感情迁移 提交于 2020-01-10 18:10:20

问题


When I compile the following code

cursor = activity.managedQuery( imageUri, proj, null, null, null );

I get following warning

The method managedQuery(Uri, String[], String, String[], String) from the type Activity is deprecated

The code is working fine. What should I do to avoid this?


回答1:


The managedQuery method is deprecated, meaning it should no longer be used and there is an updated method available. The replacement for this is getContentResolver().query():

cursor = activity.getContentResolver().query(imageUri, proj, null, null, null);

You can normally find out why the method is deprecated, and what you should use instead, by a quick Google of the method name, or depending on how good the javadoc is it may inform you through your IDE.




回答2:


The above answer is very apt. I just wanted to add to this thread more info as to why managedQuery is deprecated. Here is a nice explanation for why the managedQuery is replaced by getContentResovler().query()



来源:https://stackoverflow.com/questions/17739900/the-method-managedqueryuri-string-string-string-string-from-the-type-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!