title: How to store data in Database
body: <p>I'm trying to make an android app which needs a registration form. I've done something,but the problem now is that When the user input password and confirm password are same,then for click the register button the app stops unfortunately.But it works well when I give dissimilar passwords.
  Below is my code: </p>
  
  <p>TableData.java</p>
  
  <pre><code>import android.provider.BaseColumns;
  
  
  public class TableData {
  
  public TableData()
  {
  
  }
  
  public static abstract class TableInfo implements BaseColumns
  {
      public static final String USER_NAME = "user_name";
      public static final String USER_PASS = "user_pass";
      public static final String DATABASE_NAME = "user_info";
      public static final String TABLE_NAME = "reg_info";
      }
  }
  </code></pre>
  
  <p>DatabaseOperations.java</p>
  
  <pre><code>import android.content.ContentValues;
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;
  
  
  public class DatabaseOperations extends SQLiteOpenHelper{
      public static final int database_version = 1;
      public String CREATE_QUERY = "CREATE_TABLE" + TableData.TableInfo.TABLE_NAME+"("+ TableData.TableInfo.USER_NAME+" TEXT,"+ TableData.TableInfo.USER_PASS+" TEXT );" ;
  
  
  public DatabaseOperations(Context context) {
  
  
      super(context, TableData.TableInfo.DATABASE_NAME, null, database_version);
      Log.d("Database operations", "Database Created");
  }
  
  @Override
  public void onCreate(SQLiteDatabase sdb) {
  
      sdb.execSQL(CREATE_QUERY);
      Log.d("Database operations", "Table Created");
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
  }
  
  public void putInformation(DatabaseOperations dop, String name, String pass)
  {
      SQLiteDatabase SQ = dop.getWritableDatabase();
      ContentValues cv = new ContentValues();
      cv.put(TableData.TableInfo.USER_NAME, name);
      cv.put(TableData.TableInfo.USER_PASS, pass);
      long k = SQ.insert(TableData.TableInfo.TABLE_NAME, null, cv);
  
  
      Log.d("Database operations", "One Raw Inserted");
  }
  
  }
  </code></pre>
  
  <p>and register.java</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  
  public class register extends AppCompatActivity {
      EditText USER_NAME, USER_PASS, CON_PASS;
      String user_name, user_pass, con_pass;
      Button REG;
      Context ctx = this;
          protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.register);
  
          USER_NAME = (EditText) findViewById(R.id.reg_user);
          USER_PASS = (EditText) findViewById(R.id.reg_pass);
          CON_PASS = (EditText) findViewById(R.id.con_pass);
          REG = (Button) findViewById(R.id.user_reg);
          REG.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  user_name = USER_NAME.getText().toString();
                  user_pass = USER_PASS.getText().toString();
                  con_pass = CON_PASS.getText().toString();
  
              if (!(user_pass.equals(con_pass)))
              {
                  Toast.makeText(getBaseContext(),"Passwords are not matching",Toast.LENGTH_LONG).show();
                  USER_NAME.setText("");
                  USER_PASS.setText("");
                  CON_PASS.setText("");
  
              }
              else
              {
                  DatabaseOperations DB = new DatabaseOperations(ctx);
                  DB.putInformation(DB, user_name, user_pass);
                  Toast.makeText(getBaseContext(),"Registration is Successfully done",Toast.LENGTH_LONG).show();
                  finish();
  
              }
  
          }
  
      });
  }
  }
  </code></pre>
  
  <p>Please give me some suggestions how to fix it,thanks!</p>