Use TextUtils.isEmpty( someString )
String myString = null;
if (TextUtils.isEmpty(myString)) {
return; // or break, continue, throw
}
// myString is neither null nor empty if this point is reached
Log.i("TAG", myString);
Notes
- The documentation states that both null and zero length are checked for. No need to reinvent the wheel here.
- A good practice to follow is early return.