I need to create lot of helper routines for converting strings.
Something like :
String Function1(String s) {}
I would like to call them from any Activity
.
What is the best way to do this ? Do I need to create a class or not ? I was thinking just to have one separate file with all these functions. Is this a candidate for a package or not ?
Create a class with public static methods, then you can call them every where with ClassName.methodName(parameters):
Inside other classes:
That is what I would do (and actually always do).
You can and should differ between the types. Normally you group stuff like
DateUtils
,StringUtils
,AndroidUtils
,MathUtils
etc...I would go with a utility class and I always put my utility classes in a com.xxx.xxx.util package.