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?

Jason Hocker
  • 6,879
  • 9
  • 46
  • 79
  • 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? – CommonsWare Dec 12 '14 at 18:33
  • 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. – Jason Hocker Dec 12 '14 at 19:17
  • Did you found a solution for this? Seems its still a bug. – Ian Medeiros Jun 29 '17 at 20:59

0 Answers0