One of the most common things I’m adding when making an Android app is a file that contains various constant values to be used in various places. Here’s how I’d set it up.
First, create the .kt file (usually I’d name it
Constants.kt). Add the package name at the top, then add the constant variables without creating any class for them. In this example I assume that the file is on the root folder of the app. For example:
Finally, to use the constants themselves, we can just write the name without any fuss (on line 2 on the example below):