title: how to add data in the database on button click?
body: <p>I am new to Android following is my code I wants to add data in data base on the click of button but when I click on the Button my application crashes
  can anybody suggest me any solution
  here is my code:</p>
  
  <pre><code>public class Third extends Activity implements OnClickListener{
  Button btn;
  SQLiteDatabase db;
  EditText edit1;
  EditText edit2;
  EditText edit3;
  
  @Override
  protected void onCreate(Bundle icicle) {
  // TODO Auto-generated method stub
  super.onCreate(icicle);
  setContentView(R.layout.mit);
  SQLiteDatabase db;
  db = openOrCreateDatabase("doctorinfo.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
  db.setVersion(1);
  db.setLocale(Locale.getDefault());
  db.setLockingEnabled(true);
  final String CREATE_TABLE_COUNTRIES ="CREATE TABLE med_d ("+ "id INTEGER PRIMARY KEY AUTOINCREMENT,"+ "DOC_NAME TEXT,"+ "DOC_NO TEXT,"+ "DOC_EMAIL TEXT);";
  //db.execSQL(CREATE_TABLE_COUNTRIES);
  btn=(Button)findViewById(R.id.button1);
  edit1=(EditText)findViewById(R.id.editText1);
  edit2=(EditText)findViewById(R.id.editText2);
  edit3=(EditText)findViewById(R.id.editText3);
  
  btn.setOnClickListener(this);
  
  
  }
  
  @Override
  public void onClick(View arg0) {
  String d=edit1.getText().toString();
  String m=edit2.getText().toString();
  String p=edit3.getText().toString();
  
  ContentValues values = new ContentValues();
  values.put("DOC_NAME",d );
  values.put("DOC_NO",m);
  values.put("DOC_EMAIL",p);
  //long countryId = db.insert("med_d", null, values);
  //try {
  db.insertOrThrow("med_d", null,values);
  }// catch (Exception e) {
  //Log.e("Add Error", e.toString());
  //e.printStackTrace();
  //}
  
  
  
  }
  </code></pre>