title: Android drawing a line to follow your finger
body: <p>based on the answer of this question:<a href="https://stackoverflow.com/questions/4300399/android-drawing-a-line-to-follow-your-finger">Android drawing a line to follow your finger</a></p>
  
  <p>I tried my solution (see the code), but i get a shape like spaghetti.. How to get rid of the previous lines? I want to draw a straight line like in Microsoft Paint.</p>
  
  <p>here's my code:</p>
  
  <pre><code>@Override
  public boolean onTouchEvent(MotionEvent event) {
  
  
  
      switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
  
            downx = event.getX();
            downy = event.getY();
          invalidate();
  
          break;
      case MotionEvent.ACTION_MOVE:
          upx = event.getX();
          upy = event.getY();
          mCanvas.drawLine(downx, downy, upx, upy, mPaint);
  
          invalidate();
  
          break;
      case MotionEvent.ACTION_UP:
          upx = event.getX();
            upy = event.getY();                 
           mCanvas.drawLine(downx, downy, upx, upy, mPaint);
          invalidate();
  
          break;
      }
      return true;
  }
  </code></pre>
  
  <p>Thank you all!</p>
  
  <p>PS: It's not duplicated question,i explained above!</p>