I am creating a database and trying to insert and retrieve values. But when I try to insert values the following error is shown on Logcat

table Sample has no column named PosY (code 1): , while compiling: INSERT INTO Sample(Name,No,PosY,Img,PosX) VALUES (?,?,?,?,?)

This is the code for SQLiteOpenHelper class

public class SQL extends SQLiteOpenHelper {

```
public static final String DB_NAME="New.db";
public static final String TABLE_NAME="Sample";
public static final int DB_VERSION=1;

public static final String NAME="Name";
public static final String NO="No";
public static final String IMG="Img";
public static final String PIXELX="PosX";
public static final String PIXELY="PosY";

Cursor cur;
byte[] blob;
String name;
String no;
int pixelx,pixely;
Bitmap bmp;

Context ctxt;

private SQLiteDatabase mDb;

public SQL(Context context)
{
    super(context,DB_NAME,null,1);
}
public void onCreate(SQLiteDatabase db)
{
db.execSQL("CREATE TABLE "+TABLE_NAME+"("+NAME +" TEXT "+","+ NO +" TEXT PRIMARY KEY ,"+IMG +" BLOB,"+PIXELX +" INTEGER, "+ PIXELY +"INTEGER);");
}
public void onUpgrade(SQLiteDatabase db,int old,int newversion)
{
    db.execSQL("DROP TABLE IF EXISTS"+TABLE_NAME+";");
    onCreate(db);
}
public void drop(SQLiteDatabase db)
{
    db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME+" ;");
}
public void open(SQLiteDatabase db)
{
    db=this.getWritableDatabase();
}
public void close(SQLiteDatabase db)
{
    db.close();
}

public void insert(SQLiteDatabase db,String name,String no,byte[] ImgData,int pixelx,int pixely)
{
    db=this.getWritableDatabase();
    ContentValues con=new ContentValues();
    con.put(NAME, name);
    con.put(NO, no);
    con.put(IMG, ImgData);
    con.put(PIXELX, pixelx);
    con.put(PIXELY, pixely);
    db.insert(TABLE_NAME, null, con);
}

@SuppressLint("NewApi") public User  retrieve  (SQLiteDatabase db,String name) throws Exception
{
    cur=db.query(true,TABLE_NAME, new String[]{NAME,NO,IMG,PIXELX,PIXELY},"NAME="+name+" ", null,null, null,null, null,null);
    //cur=db.query(TABLE_NAME, new String[]{IMG},null, null,null, null, null);

    if(cur.moveToFirst())
    {
        name=cur.getString(cur.getColumnIndex(NAME));
        no=cur.getString(cur.getColumnIndex(NO));
         blob=cur.getBlob(cur.getColumnIndex(IMG));
         pixelx=cur.getInt(cur.getColumnIndex(PIXELX));
         pixely=cur.getInt(cur.getColumnIndex(PIXELY));
        cur.close();
        return new User(name,no,Utility.getPhoto(blob),pixelx,pixely);
    }
        cur.close();
        return null;
}

```

}

My code to try to insert data into the database is

```
public class Register extends Activity {
     ImageView img;
     String picpath;
     Bitmap bmp;
     Canvas cnvs;
     Random r;
     int x,y,height,width;
     ByteArrayOutputStream blob;
     SQL sql;
     Paint paint;
     String name,no;
     Uri data;
     SQLiteDatabase db;
     String[] filePath={MediaStore.Images.Media.DATA};;
     Cursor cur;
     TextView txt;
     int colIndex;
     byte[] imgData;

    public Register()
    {

    }

    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);

        img=(ImageView)findViewById(R.id.imageView1);
        sql=new SQL(this);
        db=sql.getWritableDatabase();
        sql.drop(db);
        sql.onCreate(db);
        r=new Random();
        paint=new Paint();
        x=r.nextInt(100);
        blob=new ByteArrayOutputStream();

        Intent i=getIntent();
        name=i.getStringExtra("name");
        no=i.getStringExtra("no");
        //Open Button
        Button open=(Button)findViewById(R.id.button3);
        open.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent gal_open=new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                startActivityForResult(gal_open,1);

            }
        });
        txt=(TextView)findViewById(R.id.textView1);

        Button shuffle=(Button)findViewById(R.id.button2);
        shuffle.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                bmp=Bitmap.createBitmap(img.getHeight(),img.getWidth(),Bitmap.Config.RGB_565);
                cnvs=new Canvas(bmp);

                height=img.getMeasuredHeight();
                width=img.getMeasuredWidth();
                x=r.nextInt(height);
                y=r.nextInt(width);
                paint.setColor(Color.RED);

                //data=intentData.getData();

                //cur=getContentResolver().query(data,filePath,null,null,null );
                //cur.moveToFirst();

                //colIndex=cur.getColumnIndex(filePath[0]);
                //picpath=cur.getString(colIndex);
                //cur.close();
                txt.setText(x+","+y);
                cnvs.drawBitmap(BitmapFactory.decodeFile(picpath), 0, 0, null);
                cnvs.drawRect(x, y,x+20,y+20 , paint);
                img.setImageBitmap(bmp);
                 /*height=img.getMeasuredHeight();
                 width=img.getWidth();

                //Random r=new Random();
                x=r.nextInt(width);
                y=r.nextInt(height);

                cnvs.drawBitmap(BitmapFactory.decodeFile(picpath), 0, 0, null);
                cnvs.drawRect(x, y,x+50,y+50 , paint);
                img.setImageBitmap(bmp);*/

            }
        });
        Button ok= (Button)findViewById(R.id.button1);
        txt=(TextView)findViewById(R.id.textView1);

        ok.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                txt.setText(x+"'"+y);
                bmp.compress(CompressFormat.JPEG,100, blob);
                imgData=blob.toByteArray();
                sql.insert(db,name,no,imgData,x,y); 

            }
        });
    }
    public void onDraw()
    {

    }
    public void onActivityResult(int requestCode,int resultCode,Intent intentData)
    {
        super.onActivityResult(requestCode, resultCode, intentData);
        if(requestCode==1 && resultCode==RESULT_OK && intentData!=null)
        {

            bmp=Bitmap.createBitmap(img.getHeight(),img.getWidth(),Bitmap.Config.RGB_565);
            cnvs=new Canvas(bmp);

            height=img.getMeasuredHeight();
            width=img.getMeasuredWidth();
            x=r.nextInt(height);
            y=r.nextInt(width);
            paint.setColor(Color.RED);

            data=intentData.getData();

            cur=getContentResolver().query(data,filePath,null,null,null );
            cur.moveToFirst();

            colIndex=cur.getColumnIndex(filePath[0]);
            picpath=cur.getString(colIndex);
            cur.close();

            txt=(TextView)findViewById(R.id.textView1);
            txt.setText(x+","+y);
            cnvs.drawBitmap(BitmapFactory.decodeFile(picpath), 0, 0, null);
            cnvs.drawRect(x, y,x+20,y+20 , paint);
            img.setImageBitmap(bmp);

        }   

    }

}

```

Can you please say where I have gone wrong? Thanks in advance