Android check null or empty string in Android

前端 未结 10 1509
梦如初夏
梦如初夏 2020-12-13 12:07

In my trying AsyncTask I get email address from my server. In onPostExecute() I have to check is email address empty or null

10条回答
  •  误落风尘
    2020-12-13 12:36

    Checking for empty string if it is equal to null, length is zero or containing "null" string

    public static boolean isEmptyString(String text) {
            return (text == null || text.trim().equals("null") || text.trim()
                    .length() <= 0);
        }
    

提交回复
热议问题