am a php coder who's relatively new to Android programming and I was just wondering....I have a few functions which recur in every activity. Normally in php, I would put all these recurring functions in a file functions.php
and include in each php page as include('functions.php ');
. Is it possible to achieve the same in Android programming? Thanks in advance.
Java is an object oriented language and therefore you can't define a function (static or not) that doesn't belong to an object. What you can do, however, is to define a class of all static methods like this:
public class Utils {
public static void function1() { ... }
public static String function2() { ... }
}
and then call them in other classes using the Utils.function1();
notation.