title: Not able to add new record to sqlite database android
body: <p>I am tring to add new record in my sqlite database. I am not getting any error but also not seen any kind of record in database when i see database using sqlite manager
  following is the code which i have written. plz help me to get out of this problem.</p>
  
  <p>following is my code of database handler ..</p>
  
  <pre><code>enter code here
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteDatabase.CursorFactory;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;
  import android.widget.Toast;
  
  public class DatabaseHandler extends SQLiteOpenHelper
  {
  
  private static final int DATABASE_VERSON=1;
  private static final String DATABASE_NAME="Info_manager";
  private static final String TABLE_DETAILS = "info_detail";
  
  // Contacts Table Columns names
  private static final String KEY_ID = "id";
  private static final String KEY_FNAME = "f_name";
  private static final String KEY_LNAME = "l_name";
  private static final String KEY_PH_NO = "c_num";
  private static final String KEY_EMAIL = "e_mail";
  
  
  
  public DatabaseHandler(Context context) 
  {
      super(context,null , null, 1);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) 
  {
      //db = this.getWritableDatabase();
      ///System.out.println("----333------");
      String CREATE_DETAILS_TABLE = "CREATE TABLE " + TABLE_DETAILS 
      + "("
      + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_FNAME + " TEXT," + KEY_LNAME + " TEXT," + KEY_PH_NO + " TEXT," + KEY_EMAIL + " TEXT " + ")";
  
      db.execSQL(CREATE_DETAILS_TABLE);
      ///System.out.println("----444------");
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
  {
      // Drop older table if existed
      db.execSQL("DROP TABLE IF EXISTS " + TABLE_DETAILS);
      // Create tables again
      onCreate(db);
  
  }
  
  
   // Adding new contact
  void addContact(Contact contact) 
  {
      SQLiteDatabase db = this.getWritableDatabase();
     // ContentValues values = new ContentValues();
  
      String sql;
      sql = "INSERT INTO info_detail (f_name, l_name, c_num, e_mail) " + 
      "VALUES ('" + contact.getfName().toString() + "', '" + contact.getlName().toString() + "', '" + contact.getContactNumber().toString()+ "', '" + contact.getEmailAddress().toString() +"' )";
  
      db.execSQL(sql);
  
      /*values.put(KEY_FNAME, contact.getfName());
      values.put(KEY_LNAME, contact.getlName());
      values.put(KEY_PH_NO, contact.getContactNumber());
      values.put(KEY_EMAIL, contact.getEmailAddress());*/
      // Inserting Row
      System.out.print("----inserting----");
      //db.insert(TABLE_DETAILS, null, values);
  
      System.out.print("----inserted----");
      db.close(); 
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and following is the activity from which i called handler</p>
  
  <pre><code>public class SQLitelActivity extends Activity implements OnClickListener 
  {
  
  EditText fname,lname,con_num,email_adr;
  Button savebtn,viewbtn;
  DatabaseHandler db;
  //SQLiteDatabase db;
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_sqlitel);
  
      fname=(EditText)findViewById(R.id.fname);
      lname=(EditText)findViewById(R.id.lname);
      con_num=(EditText)findViewById(R.id.cnumber);
      email_adr=(EditText)findViewById(R.id.email);
  
      savebtn=(Button)findViewById(R.id.save);
      viewbtn=(Button)findViewById(R.id.view);
  
      db=new DatabaseHandler(this);
  
      savebtn.setOnClickListener(new OnClickListener() 
      {
          @Override
          public void onClick(View v) 
          {
              //System.out.println("----111------");
              db.addContact(new Contact(fname.getText().toString()
                      , lname.getText().toString(),con_num.getText().toString(),email_adr.getText().toString()));
          //  System.out.println("----222------");
          }
      }
      );
  </code></pre>