Android Studio Tip #1 – Extract Constants

If you have hardcoded strings that should be extracted into constants, you can do that in at least 2 ways:

  • the hard way
  • the EASY way

The hard way  is to write yourself the constant and then replace it in the entire code where the string is used. And the EASY way  is to use the power of Android Studio 🙂 So in order to extract a constant you have to do the following steps:

  • select the string that needs to be converted into a constant
  • use CTRL + ALT + C (on Windows) or Cmd + ALT + C (on Mac OS)

extract constant