Dil*_*shi 14 java android deprecated
当我编译以下代码时
cursor = activity.managedQuery( imageUri, proj, null, null, null );
Run Code Online (Sandbox Code Playgroud)
我得到以下警告
不推荐使用类型为Activity的managedQuery(Uri,String [],String,String [],String)方法
代码工作正常.我该怎么做才能避免这种情况?
Cod*_*gue 42
该managedQuery方法已弃用,这意味着它不应再使用,并且有可用的更新方法.替换为getContentResolver().query():
cursor = activity.getContentResolver().query(imageUri, proj, null, null, null);
Run Code Online (Sandbox Code Playgroud)
您通常可以通过方法名称的快速Google,或者根据javadoc的优异程度,通过IDE通知您,找出该方法被弃用的原因,以及应该使用的方法.