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

后端 未结 2 1131
深忆病人
深忆病人 2021-01-01 21:25

When I compile the following code

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

I get following warning

相关标签:
2条回答
  • 2021-01-01 22:07

    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.

    0 讨论(0)
  • 2021-01-01 22:30

    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()

    0 讨论(0)
提交回复
热议问题