Android check null or empty string in Android

前端 未结 10 1511
梦如初夏
梦如初夏 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:19

    My simple solution to test if a string is null:

    if (s.equals("null")){ ..... }

    There are two cases.

    The variable (of type String) is null(doesn't exists): == works.

    The variable has a null value, *.equals("null") gives te right boolean value.

    See the picture.

提交回复
热议问题