title: android if condition not null EditText
body: <p>i have some problems in here. i have activities in my aplication insert data to database and then move to next activities when button submit has pressed. in this activities i want to make if condition when button submit pressed, if some variable in EditText null (user didn't write it) then will show Toast or messege that inform "your entry data isn't complete" so user must write it something in my EditText that.
  This is my code</p>
  
  <pre><code>package com.asrimobile;
  
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.IOException;
  
  import android.os.Bundle;
  import android.os.Environment;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.View;
  import android.view.Window;
  import android.view.View.OnClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Spinner;
  import android.widget.Toast;
  
  public class CreateData extends Activity implements OnClickListener{
  
      //inisilisasi elemen-elemen pada layout
  
      private String array_spinner[];
      private String array_spinner1[];
  
      private Button buttonSubmit;
      private EditText edAgen;
      private EditText edNo_kk;
      private EditText edNo_blanko;
      private EditText edNama;
      private EditText edAlamat;
      private EditText edJml_tertanggung;
      private Spinner edPilihan;
      private EditText edTelepon;
      private EditText edTertanggung1;
      private Spinner edStatus1;
      private EditText edTertanggung2;
      private Spinner edStatus2;
      private EditText edTertanggung3;
      private Spinner edStatus3;
      private EditText edTertanggung4;
      private Spinner edStatus4;
      private EditText edTertanggung5;
      private Spinner edStatus5;
      private EditText edTertanggung6;
      private Spinner edStatus6;
  
      private EditText edTertanggung7;
      private Spinner edStatus7;
      private EditText edTertanggung8;
      private Spinner edStatus8;
      private EditText edTertanggung9;
      private Spinner edStatus9;
      private EditText edTertanggung10;
      private Spinner edStatus10;
  
      //inisialisasi kontroller/Data Source
      private DBDataSource dataSource;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
          setContentView(R.layout.create_data);
          getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
  
          //File file = new File("/sdcard/myconfig.txt");
          File sdcard = Environment.getExternalStorageDirectory();
          File file = new File(sdcard,"myconfig.txt");
          StringBuilder text = new StringBuilder();
  
          try {
              BufferedReader br = new BufferedReader(new FileReader(file));
              String line;
  
              while ((line=br.readLine()) != null) {
                  text.append(line);
                  text.append('\n');
              }
              br.close();
          }
          catch (IOException e) {
              e.printStackTrace();
          }
  
  
          buttonSubmit = (Button) findViewById(R.id.buttom_submit);
          buttonSubmit.setOnClickListener(this);
  
          edAgen = (EditText) findViewById(R.id.agen);
          edAgen.setText(text.toString());
          //edAgen.setVisibility(View.GONE);
          //edAgen = (EditText) findViewById(R.id.agen);
          edNo_kk = (EditText) findViewById(R.id.no_kk);
          edNo_blanko = (EditText) findViewById(R.id.no_blanko);
          edJml_tertanggung = (EditText) findViewById(R.id.jml_tertanggung);
          edNama = (EditText) findViewById(R.id.nama);
          edAlamat = (EditText) findViewById(R.id.alamat);
  
          array_spinner=new String[10];
          array_spinner[0]="A1";
          array_spinner[1]="A2";
          array_spinner[2]="A3";
          array_spinner[3]="A4";
          array_spinner[4]="A5";
          array_spinner[5]="B1";
          array_spinner[6]="B2";
          array_spinner[7]="B3";
          array_spinner[8]="B4";
          array_spinner[9]="B5";
          edPilihan = (Spinner) findViewById(R.id.pilihan_paket);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner);
          edPilihan.setAdapter(adapter);
  
          array_spinner1=new String[4];
          array_spinner1[0]=" ";
          array_spinner1[1]="SUAMI";
          array_spinner1[2]="ISTRI";
          array_spinner1[3]="ANAK";
  
          edStatus1 = (Spinner) findViewById(R.id.status1);
          ArrayAdapter&lt;String&gt; adapter1 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus1.setAdapter(adapter1);
  
          edStatus2 = (Spinner) findViewById(R.id.status2);
          ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus2.setAdapter(adapter2);
  
          edStatus3 = (Spinner) findViewById(R.id.status3);
          ArrayAdapter&lt;String&gt; adapter3 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus3.setAdapter(adapter3);
  
          edStatus4 = (Spinner) findViewById(R.id.status4);
          ArrayAdapter&lt;String&gt; adapter4 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus4.setAdapter(adapter4);
  
          edStatus5 = (Spinner) findViewById(R.id.status5);
          ArrayAdapter&lt;String&gt; adapter5 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus5.setAdapter(adapter5);
  
          edStatus6 = (Spinner) findViewById(R.id.status6);
          ArrayAdapter&lt;String&gt; adapter6 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus6.setAdapter(adapter6);
  
          edStatus7 = (Spinner) findViewById(R.id.status7);
          ArrayAdapter&lt;String&gt; adapter7 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus7.setAdapter(adapter7);
  
          edStatus8 = (Spinner) findViewById(R.id.status8);
          ArrayAdapter&lt;String&gt; adapter8 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus8.setAdapter(adapter8);
  
          edStatus9 = (Spinner) findViewById(R.id.status9);
          ArrayAdapter&lt;String&gt; adapter9 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus9.setAdapter(adapter9);
  
          edStatus10 = (Spinner) findViewById(R.id.status10);
          ArrayAdapter&lt;String&gt; adapter10 = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, array_spinner1);
          edStatus10.setAdapter(adapter10);
  
          edTelepon = (EditText) findViewById(R.id.telepon);
          edTertanggung1 = (EditText) findViewById(R.id.tertanggung1);
  
          edTertanggung2 = (EditText) findViewById(R.id.tertanggung2);
  
          edTertanggung3 = (EditText) findViewById(R.id.tertanggung3);
  
          edTertanggung4 = (EditText) findViewById(R.id.tertanggung4);
  
          edTertanggung5 = (EditText) findViewById(R.id.tertanggung5);
  
          edTertanggung6 = (EditText) findViewById(R.id.tertanggung6);
  
          edTertanggung7 = (EditText) findViewById(R.id.tertanggung7);
          edTertanggung8 = (EditText) findViewById(R.id.tertanggung8);
          edTertanggung9 = (EditText) findViewById(R.id.tertanggung9);
          edTertanggung10 = (EditText) findViewById(R.id.tertanggung10);
  
          // instanstiasi kelas DBDataSource
          dataSource = new DBDataSource(this);
  
          //membuat sambungan baru ke database
          dataSource.open();
      }
  
      //KETIKA Tombol Submit Diklik
      @Override
      public void onClick(View v) {
  
          /*String ret = "";
  
              try {
                  InputStream inputStream = openFileInput("myconfig.txt");
                  if (inputStream != null) {
                      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                      BufferedReader br = new BufferedReader(inputStreamReader);
                      String line = "";
                      StringBuilder text = new StringBuilder();
  
                  while ((line = br.readLine()) != null) {
                      text.append(line);
                  }
                  inputStream.close();
                  ret = text.toString();
                  }
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
  
              edAgen.setText(ret);*/
  
          // Inisialisasi data barang
          //String agen = edAgen.getText().toString();
          String agen = null;
          String no_kk = null;
          String no_blanko = null;
          String nama = null;
          String alamat = null;
          String jml_tertanggung = null;
          String pilihan = edPilihan.getSelectedItem().toString();
          String telepon = null;
          String tertanggung1 = null;
          String status1 = edStatus1.getSelectedItem().toString();
          String tertanggung2 = null;
          String status2 = edStatus2.getSelectedItem().toString();
          String tertanggung3 = null;
          String status3 = edStatus3.getSelectedItem().toString();
          String tertanggung4 = null;
          String status4 = edStatus4.getSelectedItem().toString();
          String tertanggung5 = null;
          String status5 = edStatus5.getSelectedItem().toString();
          String tertanggung6 = null;
          String status6 = edStatus6.getSelectedItem().toString();
  
          String tertanggung7 = null;
          String status7 = edStatus7.getSelectedItem().toString();
          String tertanggung8 = null;
          String status8 = edStatus8.getSelectedItem().toString();
          String tertanggung9 = null;
          String status9 = edStatus9.getSelectedItem().toString();
          String tertanggung10 = null;
          String status10 = edStatus10.getSelectedItem().toString();
          @SuppressWarnings("unused")
  
          //inisialisasi barang baru (masih kosong)
          Barang barang = null;
          if(edAgen.getText()!=null &amp;&amp; edNo_kk.getText()!=null &amp;&amp; edNo_blanko.getText()!=null &amp;&amp; edNama.getText()!=null &amp;&amp; edAlamat.getText()!=null &amp;&amp; edJml_tertanggung.getText()!=null &amp;&amp; //edPilihan.getContext()!=null &amp;&amp;
                  edTelepon.getText()!=null &amp;&amp; 
                  edTertanggung1.getText()!=null &amp;&amp; //edStatus1.getText()!=null &amp;&amp; 
                  edTertanggung2.getText()!=null &amp;&amp; //edStatus2.getText()!=null &amp;&amp; 
                  edTertanggung3.getText()!=null &amp;&amp; //edStatus3.getText()!=null &amp;&amp; 
                  edTertanggung4.getText()!=null &amp;&amp; //edStatus4.getText()!=null &amp;&amp; 
                  edTertanggung5.getText()!=null &amp;&amp; //edStatus5.getText()!=null &amp;&amp; 
                  edTertanggung6.getText()!=null &amp;&amp;
                  edTertanggung7.getText()!=null &amp;&amp;
                  edTertanggung8.getText()!=null &amp;&amp;
                  edTertanggung9.getText()!=null &amp;&amp;
                  edTertanggung10.getText()!=null) //edStatus6.getText()!=null)
          {
              /* jika field nama, merk, dan harga tidak kosong
               * maka masukkan ke dalam data barang*/
              agen = edAgen.getText().toString();
              no_kk = edNo_kk.getText().toString();
              no_blanko = edNo_blanko.getText().toString();
              nama = edNama.getText().toString();
              alamat = edAlamat.getText().toString();
              jml_tertanggung = edJml_tertanggung.getText().toString();
              //pilihan = edPilihan.getContext().toString();
              telepon = edTelepon.getText().toString();
              tertanggung1 = edTertanggung1.getText().toString();
              //status1 = edStatus1.getText().toString();
              tertanggung2 = edTertanggung2.getText().toString();
              //status2 = edStatus2.getText().toString();
              tertanggung3 = edTertanggung3.getText().toString();
              //status3 = edStatus3.getText().toString();
              tertanggung4 = edTertanggung4.getText().toString();
              //status4 = edStatus4.getText().toString();
              tertanggung5 = edTertanggung5.getText().toString();
              //status5 = edStatus5.getText().toString();
              tertanggung6 = edTertanggung6.getText().toString();
              //status6 = edStatus6.getText().toString();
              tertanggung7 = edTertanggung7.getText().toString();
              tertanggung8 = edTertanggung8.getText().toString();
              tertanggung9 = edTertanggung9.getText().toString();
              tertanggung10 = edTertanggung10.getText().toString();
  
          }   
  
          switch(v.getId())
          {
              case R.id.buttom_submit:
                  // insert data barang baru
                  barang = dataSource.createBarang(agen.trim(), no_kk, no_blanko, nama, alamat, jml_tertanggung, pilihan, telepon, tertanggung1, status1, tertanggung2, status2, tertanggung3, status3, tertanggung4, status4, tertanggung5, status5, tertanggung6, status6, tertanggung7, status7, tertanggung8, status8, tertanggung9, status9, tertanggung10, status10);
  
                  Intent z = new Intent(this, Otorisasi.class);
                  startActivity(z);
                  CreateData.this.finish();
                  //konfirmasi kesuksesan
                  Toast.makeText(this, "Data telah masuk..", Toast.LENGTH_LONG).show();
                  break;
  
          }
      }
  
  }
  </code></pre>
  
  <p>please help me how i must insert if condition in my code,, for example i want variable "no_kk" in there has if condition(cannot null). i tried and stuck because my variable is String and null condition is boolean.. thx for your help</p>