Does EditText.getText() ever returns null?

getText() will not return null. So there is no chance for NPE in following method. the getText will return empty string if there is no string, which is definitely not null

getText().toString();

However the edittext itself can be null if not initialized properly, Hence the following will trigger NPE

editText.getText().toString();

Leave a Comment