I have some methods that I use at various points of the applications and I end up having to copy in each class.
For example:
String getStringOrEmpty(EditText editText) {
String mString = editText.getText().toString();
mString = (mString.isEmpty() ? "" : mString);
return mString;
}
Just to inform: this method returns a String with the text that the EditText, if any, or an empty String.
I did not want to have to copy it in every class that will use it, but I would like to access this and other methods throughout the project.
This would be similar to a library of functions in other languages. For example, in php, I would make a file with a list of functions and would use an include command to import the list into the page.
How do you do this in Java (with emphasis for Android)?