title: creating a prepared statement to save values to a database
body: <p>Im trying to create a prepared statement so that when i click a button it saves a users username and password to a database for them to be able to login. But i have no idea how to do this. Any pointers? Below is my code:</p>
  
  <pre><code>public class Register extends AppCompatActivity {
  
      EditText username, password;
      Button registartion;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_register);
      }
  
      private Connection getConnection()
      {
  
          String host = "jdbc:mysql://jdbc.fmc.me.uk:3306/db_ben";
          String u = "user_ben";
          String p = "********";
          try
          {
              Connection con = DriverManager.getConnection(host, u, p);
              return con;
          } catch (SQLException e)
          {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return null;
      }
  
      private boolean registerUser(){
  
          //Get username
          EditText regUsernameBox = (EditText) findViewById(R.id.RegUsername);
          String regUsernameStr = regUsernameBox.getText().toString();
  
          //Get password
          EditText regPasswordBox = (EditText) findViewById(R.id.RegPassword);
          String regPasswordStr = regPasswordBox.getText().toString();
  
          System.out.println(regUsernameStr);
          System.out.println(regPasswordStr);
  
          return false;
      }
  
      public void buttonClick() {
          final Button registerUsers = (Button) findViewById(R.id.bRegister);
  
          registerUsers.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  registerUser();
              }
          });
     }
  }
  </code></pre>