14

I read Android documents and also I find deprecated methods and classes in that.Can I use deprecated methods and classes in android studio? Can I use them like other methods and classes that are not deprecated?

  • 1
    Yes, you can use them. But it is not recommended. – Bidhan May 17 '15 at 07:42
  • yes , you can use but they are deprecated means there is better approach arrived for that so use new ones are preferable – N J May 17 '15 at 07:43

4 Answers4

15

Yes you can use deprecated methods as long as the depreciated method exists in the framework. By deprecating a method the platform developers are trying to tell you that either something is wrong with the method or there is already better way for doing the task.

Depricating a method is like giving a warning to the developers not to use that method as the chances are high that the deprecated methods will be removed in the future release and your application which uses that method may no longer work when your users updates the platform to the latest release.

nvinayshetty
  • 3,187
  • 1
  • 21
  • 32
6

Of course you can use deprecated methods, they should still work as intended. But you have to be careful, because they could be removed in future versions. So read the comments.

This discussion gives you further information Is it wrong to use Deprecated methods or classes in Java?

The description of the Java Deprecated annotation can be found here http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Deprecated.html

It says

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.

Community
  • 1
  • 1
NaN
  • 7,441
  • 6
  • 32
  • 51
2

Of course you can use them just that they can be removed in future update which makes it dangerous for your apps and end user. To get more info read the android documentation on it. https://developer.android.com/reference/java/lang/Deprecated

RJnr
  • 670
  • 6
  • 19
1

As a victim, my advice for you is NO because there's a time i used a deprecated method of androidx ViewPager instead of the modern one. Although it worked fine but after keeping the app idle for some days, then it could no longer open if i tried to open it