title: Android: Why is the RadioButton returning a NULL value?
body: <p>I created a RadioGroup to enable the gender selection.</p>
  
  <p>Here's the part of the XML file that declares the RadioGroup and the RadioButtons.</p>
  
  <pre><code>        &lt;RadioGroup
              android:id="@+id/rgGenderGroup"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"&gt;
  
              &lt;RadioButton
                  android:id="@+id/rbMale"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="0.5"
                  android:text="@string/m"
                  android:textColor="@color/default_text"/&gt;
  
              &lt;RadioButton
                  android:id="@+id/rbFemale"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="0.5"
                  android:text="@string/f"
                  android:textColor="@color/default_text"/&gt;
  
          &lt;/RadioGroup&gt;
  </code></pre>
  
  <p>And now, in the activity, I declared the RadioGroup and RadioButton variables and overrode the onCheckedChanged method. To return a certain value of each choice, I also declared a String value.</p>
  
  <pre><code>private String gender = "";
  private RadioGroup rgGenderGroup;
  private RadioButton rbMale, rbFemale;
  
  ...
  
      @Override
      public void onCheckedChanged(RadioGroup group, int checkedId) {
          switch(checkedId) {
              case(R.id.rbMale):
                  gender = "M";
                  break;
              case(R.id.rbFemale):
                  gender = "F";
                  break;
          }
      }
  </code></pre>
  
  <p>But, as I tried to insert the gender value into the database with the query below, </p>
  
  <pre><code>private final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ( " +
          COLUMN_NAME + " TEXT NOT NULL, " + COLUMN_AGE + " INT, " + COLUMN_NATIONALITY + " TEXT NOT NULL, " +
          COLUMN_GENDER + " CHAR(1) NOT NULL, " + COLUMN_CREATED_AT + " TEXT NOT NULL);";
  </code></pre>
  
  <p>It fails, showing the following error message.</p>
  
  <pre><code>08-10 23:46:52.356  21666-21890/com.marshall.sortingtester E/SQLiteDatabase﹕ Error inserting Name=clara Age=0 Nationality=Angola Created_At=2015/08/10 23:46:52 Gender=null
      android.database.sqlite.SQLiteConstraintException: People.Gender may not be NULL (code 19)
  </code></pre>
  
  <p>Why is the gender value returning null even after checking the button properly?</p>
  
  <p>EDIT: Here's the insertData method.</p>
  
  <pre><code>public void insertData(Person person) {
          ContentValues values = new ContentValues();
          values.put(SQLiteHandler.COLUMN_NAME, person.getName());
          values.put(SQLiteHandler.COLUMN_AGE, person.getAge());
          values.put(SQLiteHandler.COLUMN_NATIONALITY, person.getNationality());
          values.put(SQLiteHandler.COLUMN_GENDER, person.getGender());
          values.put(SQLiteHandler.COLUMN_CREATED_AT, person.getCreated_at());
          db.insert(SQLiteHandler.TABLE_NAME, null, values);
      }
  </code></pre>