title: How to keep drawn things in canvas after invalidate
body: <p>for training, I'm writing something like 'achtung, die kurve' game. For now, I'm only about to simple drawing my 'kurve-snake' on screen. To turn I use accelerometer (and it does work in fact). I've custom view which has his own onDraw method.</p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      Paint paint2 = new Paint();
      paint2.setAntiAlias(true);
      paint2.setStrokeWidth(mPlayer.getLine().getmSize());
      paint2.setColor(Color.GREEN);
  
      float x = mPlayer.getLine().getmPosX();
      float y = mPlayer.getLine().getmPosY();
      mLogic.movePlayer(mBitmapPoint, mPlayer, mSensorY);
      canvas.drawLine(x,y,mPlayer.getLine().getmPosX(), mPlayer.getLine().getmPosY(), paint2);
      invalidate();
  }
  </code></pre>
  
  <p>It does work properly, but this way I can't keep whole line (just the actual fragment of it). </p>
  
  <p>I've tried other way: draw lines using bitmap.setpixel (bresenhams alg) and after it canvas.drawBitmap(...), but it's not effective.</p>
  
  <p>I've tried too: </p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      Paint paint2 = new Paint();
      paint2.setAntiAlias(true);
      paint2.setStrokeWidth(mPlayer.getLine().getmSize());
      paint2.setColor(Color.GREEN);
  
      float x = mPlayer.getLine().getmPosX();
      float y = mPlayer.getLine().getmPosY();
      mLogic.movePlayer(mBitmapPoint, mPlayer, mSensorY);
      canvas.drawLine(x,y,mPlayer.getLine().getmPosX(), mPlayer.getLine().getmPosY(), paint2);
      invalidate();
      mBitmapPoint = getDrawingCache();
  
  }
  </code></pre>
  
  <p>but it gives error. Any idea how to achieve that?</p>