Android Studio getting deprecated warning even with @SuppressWarnings("deprecation")
Asked Answered
S

0

6

In Android Studio, we are getting a deprecated warning during the build. This code is in onCreate(Bundle) of an Activity

String databasePath = webView.getContext().getDir("databases", Context.MODE_PRIVATE).getPath();
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath(databasePath);

The method has these annotations

@SuppressLint("SetJavaScriptEnabled")
@SuppressWarnings("deprecation")
@TargetApi(19)
@Override
public void onCreate(Bundle savedInstanceState) {

I know setDatabasePath is deprecated, but we need this for backwards compatibility.

I thought that would hide the warning. When we do the compile task, I see a message like

.../app/src/main/java/com/.../WebframeActivity.java Warning:(106, 15) [deprecation] setDatabasePath(String) in WebSettings has been deprecated

I thought the @SuppressWarnings annotation would not report this as a warning. What can I do? Is this a bug or am I overlooking my mistake?

Schema answered 12/12, 2014 at 18:31 Comment(3)
I only worry about those sorts of annotations affecting the IDE, not output from a command-line build. Does Android Studio itself, in the code editor, flag your deprecated code in any way?Spectroheliograph
If I have the @SuppressWarnings("deprecation") there Android Studio does not flag it. If I remove it, Android Studio does correctly show that there is a deprecated method.Schema
Did you found a solution for this? Seems its still a bug.Interscholastic

© 2022 - 2024 — McMap. All rights reserved.