drawing a plot for different points in android
<p>i have got some points (A,B) from database and want to plot those points and join them forming   a polygon type shape .Basically it will represent shape of a swimming pool cover .Now i have written the following code but the outcome is weired.Only the last drawn line exist and the lines drawn before goes away .Am i doing something wrong?? or there is a better way to do it ??</p>

<pre><code>      private void calculationForPlot(){
     ArrayList&lt;String&gt; al_edit_A_ft = new ArrayList&lt;String&gt;();

     ArrayList&lt;String&gt; al_edit_A_inch=new ArrayList&lt;String&gt;();
     ArrayList&lt;String&gt;al_edit_B_ft=new ArrayList&lt;String&gt;(); 
     ArrayList&lt;String&gt;al_edit_B_inch= new ArrayList&lt;String&gt;();
    float x=0;
     AndroidOpenDbHelper androidOpenDbHelperObj = new AndroidOpenDbHelper(this);
        SQLiteDatabase sqliteDatabase = androidOpenDbHelperObj.getReadableDatabase();
        String q="SELECT * FROM ab_measurement WHERE job_id=" +"\""+Settings.jobid +"\"";


   Cursor  cursor = sqliteDatabase.rawQuery(q,null);

        if (cursor.moveToNext()) {
            System.out.println(cursor.getCount());
        int m=Integer.parseInt(cursor.getString(4));

            do {
                try{

                float a = 0,b = 0;



                 a=(float) Double.parseDouble(cursor.getString(6));
                 String number =String.valueOf(a);
                 System.out.println("aaa ggg"+number);
                 String int_part =number.substring(0,number.indexOf("."));
                 String float_part=number.substring(number.lastIndexOf(".")+1,number.length());
                 System.out.println("aaa values"+int_part);
                 System.out.println("aaa values"+float_part);


                  al_edit_A_ft.add(int_part);
                  al_edit_A_inch.add(float_part);

                     b= (float) Double.parseDouble(cursor.getString(7));
                     String number_b =String.valueOf(b);
                     System.out.println("aaa ggg"+number_b);
                     String int_part_b =number_b.substring(0,number_b.indexOf("."));
                     String float_part_b=number_b.substring(number_b.lastIndexOf(".")+1,number_b.length());
                     System.out.println("aaa values"+int_part_b);
                     System.out.println("aaa values"+float_part_b);
                     al_edit_B_ft.add(int_part_b);
                     al_edit_B_inch.add(float_part_b);

                     x= (float) Double.parseDouble(cursor.getString(3));
                     String ft_base =String.valueOf(x);
                     System.out.println("aaa ggg"+ft_base);
                     String int_part_ft =ft_base.substring(0,ft_base.indexOf("."));
                     String float_part_inch=ft_base.substring(ft_base.lastIndexOf(".")+1,ft_base.length());
                     System.out.println("aaa values"+int_part_ft);
                     System.out.println("aaa values"+float_part_inch);


                }
                catch (Exception e) {

                }

            } while (cursor.moveToNext());

    if(m&gt;0){
        float pixelPerUnit=240/x;

        if(x&gt;0){
            float X_prev=110;
            float Y_prev=250;
            float X = 0;
            float Y = 0;

            drawPlot(X_prev,Y_prev, X_prev+1, Y_prev+1);//origin
            for(int i=0;i&lt;/*obj.*/m;i++){
                String str_pointA=al_edit_A_ft.get(i).concat(".").concat(al_edit_A_inch.get(i));
                float pointA= (float) (Double.parseDouble(str_pointA)*pixelPerUnit);

                String str_pointB=al_edit_B_ft.get(i).concat(".").concat(al_edit_B_inch.get(i));
                float pointB=(float) (Double.parseDouble(str_pointB)*pixelPerUnit);

                float d = 240;
                if (pointB&lt;1) {
                    X =  (110+(pointA/2));
                }
                else if (pointA&lt;1){
                    Y = (110-(pointB/2));
                }else{
                     float a = (pointA * pointA - pointB * pointB + d * d ) / (2 * d);
                      float h = (float) Math.abs(Math.sqrt( pointA * pointA - a * a ));

                        if (h&lt;0){
                            h=0;
                        }

                        X  = (110+(a/2)) ;
                        Y  =  (250-h);   
                      }

                System.out.println("X and Y"+"  "+X+"  "+Y);
                      drawPlot(X_prev+1, Y_prev_+1, X, Y);


                       X_prev=X;
                       Y_prev=Y;
                    }

            drawPlot(X_prev, Y_prev, 110, 250);//to complete the loop

            }

        }
    }
    }

        private void drawPlot(float startX,float startY,float endX,float endY) {
    System.out.println("Draw plot called");
     bitmap = Bitmap.createBitmap((int) getWindowManager()
                .getDefaultDisplay().getWidth(), (int) getWindowManager()
                .getDefaultDisplay().getHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            drawingImageView.setImageBitmap(bitmap);


            Paint paint = new Paint();
            paint.setColor(Color.BLUE);
            paint.setStrokeWidth(2);

            canvas.drawLine(startX, startY, endX, endY, paint);


}
</code></pre>
