I am developing an android application.I am getting a String value as null from webservice. I am fetching the value and storing it in a String variable. Then when I print the value using Log, like Log.i("tag", "````!!!cell >>"+cell);, I an getting null printed in the screen. Now what i need is that I need to check the variable for 'null' and I want to display a textfield with no value if it is 'null'. I am using the following statement for checking
if(!cell.equals(null) || !cell.equals("")) {
_______
} else {
_______
}
But the control is not going inside the else part if the value us 'null'
Please give me a solution.
Thanks in advance.
when cell
is null , and you are trying to invoke a method on it, you will hit by a null pointer exception.
I'd say
if(cell !=null && !cell.isEmpty()) {
_______yes, disply
} else {
_______nope, some thing wrong
}
its not equals(null)
its
if(cell != null || !cell.isEmpty())
Try TextUtils.html#isEmpty(java.lang.CharSequence)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With