title: draw line- Android
body: <p>I want to draw a line on screen using touch listener, but when i try to draw line again it erases the previous line. I am using this code:-</p>
  
  <p>I am unable to find a solution to the problem. </p>
  
  <pre><code>public class Drawer extends View
  {
      public Drawer(Context context)
      {
          super(context);
      }
  
      protected void onDraw(Canvas canvas)
      {
          Paint p = new Paint();
          p.setColor(colordraw);
          canvas.drawLine(x1, y1, x2, y2, p);
          invalidate();
      }
  }
  </code></pre>