Peki burdaki kodlara nasıl ekleyebilirim bu kod parçasını.
ublic class MainActivity extends AppCompatActivity {
Button kayt;
EditText isim, soyisim, sifre, tkr_sifre, email, htr_soru;
private Veritabani v1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
v1 = new Veritabani(this);
kayt = (Button) findViewById(R.id.button);
isim = (EditText) findViewById(R.id.editText);
soyisim = (EditText) findViewById(R.id.editText2);
email = (EditText) findViewById(R.id.editText3);
sifre = (EditText) findViewById(R.id.editText4);
tkr_sifre = (EditText) findViewById(R.id.editText5);
htr_soru = (EditText) findViewById(R.id.editText6);
kayt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ekleme(isim.getText().toString(), soyisim.getText().toString(), email.getText().toString(), sifre.getText().toString(),
tkr_sifre.getText().toString(), htr_soru.getText().toString());
Toast.makeText(getApplicationContext(), "KAYIT YAPILDI!", Toast.LENGTH_LONG).show();
Intent i = new Intent(getApplicationContext(), Main2Activity.class);
startActivity(i);
}
});
}
private void ekleme (String isim, String soyisim,String email,String sifre,String tkr_sifre,String htr_soru){
SQLiteDatabase db=v1.getWritableDatabase();
ContentValues cv1=new ContentValues();
cv1.put("isim",isim);
cv1.put("soyisim",soyisim);
cv1.put("email",email);
cv1.put("sifre",sifre);
cv1.put("tkr_sifre",tkr_sifre);
cv1.put("htr_soru", htr_soru);
db.insertOrThrow("kayit", null, cv1);