paint like Ms Paint in the activity
<p>I am new to Android and I have developed an application like ms paint to paint <code>bitmap</code> as background on <code>canvas</code> <code>surfaceview</code> with selected color from the color picker <code>Dialog</code>. previous drawing color is changed to new drawing color, However i want the previous drawing color line to remain, and new drawing color line with new color. Any one help?</p>

<pre><code>public class CanvasButtonActivity extends Activity implements Runnable,
    ColorPickerDialog.OnColorChangedListener {

private Button btn1, btn2;
private SurfaceView surface;
private SurfaceHolder holder;
private boolean locker = true;
private Thread thread;
private Path mPath;
TextView tv;
private Paint mPaint;
Canvas canvas;

// private Paint mBitmapPaint;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_canvas_button);

    btn1 = (Button) findViewById(R.id.Color);
    btn2 = (Button) findViewById(R.id.Erase);
    tv = (TextView) findViewById(R.id.txt);
    surface = (SurfaceView) findViewById(R.id.mysurface);
    holder = surface.getHolder();

    // mBitmapPaint = new Paint(Paint.DITHER_FLAG);

    mPaint = new Paint();
    mPath = new Path();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(0xFFFF0000);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(12);

    thread = new Thread(this);
    thread.start();
    btn1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            new ColorPickerDialog(CanvasButtonActivity.this,
                    CanvasButtonActivity.this, mPaint.getColor()).show();
        }
    });

    btn2.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // mPaint.setXfermode(new
            // PorterDuffXfermode(PorterDuff.Mode.CLEAR));
            // icon.eraseColor(Color.TRANSPARENT);
            // canvas.drawColor(Color.BLACK);
            mPath.reset();
            // mPaint.reset();
            mPaint = new Paint();
            mPaint.setColor(Color.BLACK);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeJoin(Paint.Join.ROUND);
            mPaint.setStrokeCap(Paint.Cap.ROUND);
            mPaint.setStrokeWidth(12);

            canvas.drawPath(mPath, mPaint);
            // canvas.drawColor(0, Mode.CLEAR);
        }
    });
}

// private Paint mPaint;
@Override
public void colorChanged(int color) {
    // TODO Auto-generated method stub
    mPaint.setColor(color);
    tv.setTextColor(color);

}

@Override
public void run() {
    // TODO Auto-generated method stub
    while (locker) {
        canvas = null;
        try {
            if (!holder.getSurface().isValid()) {
                continue;
            }
            canvas = holder.lockCanvas();

            draw(canvas);

        } finally {
            if (canvas != null) {
                holder.unlockCanvasAndPost(canvas);
            }
        }
    }
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        // mPath = new Path();
        // mPath.reset();
        mPath.moveTo(event.getX(), event.getY());
        // mPath.lineTo(event.getX(), event.getY());
    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
        mPath.lineTo(event.getX(), event.getY());
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        mPath.lineTo(event.getX(), event.getY());
    }
    return true;
}

/**
 * This method deals with paint-works. Also will paint something in
 * background
 */
private void draw(Canvas canvas) {
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
            R.drawable.bell);
    // canvas.drawColor(Color.CYAN);
    canvas.drawBitmap(bitmap, 20, 20, mPaint);
    // canvas.setBitmap(bitmap);
    canvas.drawPath(mPath, mPaint);

}
</code></pre>

<p>}</p>
