Android TextUtils isEmpty vs String.isEmpty

Yes, TextUtils.isEmpty(string) is preferred.


For string.isEmpty(), a null string value will throw a NullPointerException

TextUtils will always return a boolean value.

In code, the former simply calls the equivalent of the other, plus a null check.

return string == null || string.length() == 0;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)