title: Empty Field validation in Android
body: <p>I want to validate empty field and then perform simple calculation. But my code is not working. </p>
  
  <p>My code:    </p>
  
  <pre><code>public void onClick(View v) 
            {
              Double value = Double.parseDouble(etValue.getText().toString());
              Double answer = (double) 0;
              if(etValue.getText().toString().equals("")){
                  Toast.makeText(getApplicationContext(), "Please Enter Value", Toast.LENGTH_LONG).show();
              }
              else{
  
                      if((spBitsBytesFrom.getSelectedItem().toString().equals("Bits")) &amp;&amp; (spBitsBytesTo.getSelectedItem().toString().equals("Bytes")))
                      {
  
                          answer = value/8;
                          String stringAnswer = Double.toString(answer);
                          Answer.setText(stringAnswer);
                      }
                  }
            }
  </code></pre>