'Where to put "general" functions in Android?

I want to write a general function for my project that will be used across many different files and I don't want to have it in a particular class.

Where am I supposed to put it?
Inside a new package as a class?

Is this the only option?



Solution 1:[1]

In Java every method lives in a class. So yes, its the only option. A common approach is to use a utility class containing only static methods. You can use it from everywhere without creating any instances.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henry