title: SQLite -android studio- "table products has no column named"
body: <pre><code>    package com.example.mohamed.myapplication;
  
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  /**
   * Created by mohamed on 5/22/2016.
   */
  public class MyDBHandler extends SQLiteOpenHelper {
  
      private static final int DB_VERSION=2;
      private static final String DB_NAME="products.db";
      public static final String TABLE_PRODUCTS="products";
      public static final String Column_id="_id";
      public static final String Column_Products="productname";
  
      public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
          super(context, DB_NAME, factory, DB_VERSION);
      }
  
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          String query = "CREATE TABLE " + TABLE_PRODUCTS + "(" +
                  Column_id +" INTEGER PRIMARY KEY AUTOINCREMENT ," +
                  Column_Products + " TEXT " +
                  ");";
          db.execSQL(query);
      }
  
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
          db.execSQL("DROP TABLE IF EXISTS " + TABLE_PRODUCTS);
          onCreate(db);
      }
  
      public void addproduct (Products product){
  
          ContentValues values=new ContentValues();
          values.put(Column_Products,product.get_productname());
          SQLiteDatabase db=getWritableDatabase();
          db.insert(TABLE_PRODUCTS, null, values);
          db.close();
  
      }
      public void deleteproduct (String productname)
      {
  
          SQLiteDatabase db=getWritableDatabase();
          db.execSQL("DELETE FROM " + TABLE_PRODUCTS +"WHERE" +Column_Products + "=\"" + productname + "\";");
  
      }
  
      public String DatabaeToString(){
          String dbstring ="";
          SQLiteDatabase db=getWritableDatabase();
          String query ="SELECT * FROM " + TABLE_PRODUCTS +" WHERE 1";
  
          Cursor c = db.rawQuery(query,null);
          c.moveToFirst();
  
          while (!c.isAfterLast()){
              if(c.getString(c.getColumnIndex("productname"))!=null){
              dbstring +=c.getColumnIndex("productname");
              dbstring +="\n" ;
              }
          }
          return dbstring;
  
      }
  }
  </code></pre>
  
  <p>[Logcat scrshot][2]
  **i have worked one day on fixing this code table products has no column named productname **android.database.sqlite.SQLiteException: table products has no column named productname (code 1): , while compiling: INSERT INTO products(productname) VALUES (?)</p>
  
  <p><a href="http://i.stack.imgur.com/OIYr9.png" rel="nofollow">Logcat screen shot</a></p>