how to change color from color picker but previous drawing color not change
<p>When i choose the color from Color Picker then previous drawing color has been change with new color. While it would not be change. I also perform the undo redo operation in this application. If i perform the Undo/Redo then i can't change background Color .</p>

<pre><code>  public class MainActivity extends Activity implements OnColorChangedListener{

    LinearLayout linearLayout2;
    private ArrayList&lt;Path&gt; undonePaths = new ArrayList&lt;Path&gt;();
    private ArrayList&lt;Path&gt; paths = new ArrayList&lt;Path&gt;();
    int bckcolor=0xffff000f;
    private static final String COLOR_PREFERENCE_KEY = "color";  
    public static int selectedColor = Color.BLACK;
    Paint mPaint;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
    final DrawingPanel dp = new DrawingPanel(this);

    Button btnsave=(Button)findViewById(R.id.button4);
    btnsave.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }
    });
    Button btncolor=(Button)findViewById(R.id.button3);
    btncolor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // TODO Auto-generated method stub
            int color = PreferenceManager.getDefaultSharedPreferences(
                    MainActivity.this).getInt(COLOR_PREFERENCE_KEY, Color.WHITE);
            new ColorPickerDialog(MainActivity.this, MainActivity.this, color).show();
        }
    });
    linearLayout2.addView(dp);
    ((Button) findViewById(R.id.button1))
            .setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    if (paths.size() &gt; 0) {
                        undonePaths.add(paths
                                .remove(paths.size() - 1));
                        dp.invalidate();
                    }
                }
            });
    ((Button) findViewById(R.id.button2))
    .setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
             if (undonePaths.size()&gt;0) {
                   paths.add(undonePaths.remove(undonePaths.size()-1));
                   dp.invalidate();
               }
        }
    });
}

public class DrawingPanel extends View implements OnTouchListener {

    private Canvas mCanvas;
    private Path mPath;
    private Paint mPaint, circlePaint, outercirclePaint;

    // private ArrayList&lt;Path&gt; undonePaths = new ArrayList&lt;Path&gt;();
    private float xleft, xright, xtop, xbottom;

    public DrawingPanel(Context context) {
        super(context);
        setFocusable(true);
        setFocusableInTouchMode(true);

        this.setOnTouchListener(this);

        circlePaint = new Paint();
        mPaint = new Paint();
        outercirclePaint = new Paint();
        outercirclePaint.setAntiAlias(true);
        circlePaint.setAntiAlias(true);
        mPaint.setAntiAlias(true);
        mPaint.setColor(Color.CYAN);
        outercirclePaint.setColor(0x44FFFFFF);
        circlePaint.setColor(0xAADD5522);
        outercirclePaint.setStyle(Paint.Style.STROKE);
        circlePaint.setStyle(Paint.Style.FILL);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(6);
        outercirclePaint.setStrokeWidth(6);
        mCanvas = new Canvas();
        mPath = new Path();
        paths.add(mPath);
    }

    public void colorChanged(int color) {
        mPaint.setColor(color);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int colorPicked = MainActivity.selectedColor;
        Paint paint1 = createPen(colorPicked);
        for (Path p : paths) {
            canvas.drawPath(p, paint1);
        }

    }

    private Paint createPen(int colorPicked) {
        // TODO Auto-generated method stub
        mPaint = new Paint();
        mPaint.setColor(colorPicked);
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(3);
        return mPaint;
    }

    private float mX, mY;
    private static final float TOUCH_TOLERANCE = 0;

    private void touch_start(float x, float y) {
        mPath.reset();
        mPath.moveTo(x, y);
        mX = x;
        mY = y;
    }

    private void touch_move(float x, float y) {
        float dx = Math.abs(x - mX);
        float dy = Math.abs(y - mY);
        if (dx &gt;= TOUCH_TOLERANCE || dy &gt;= TOUCH_TOLERANCE) {
            mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
            mX = x;
            mY = y;
        }
    }

    private void touch_up() {
        mPath.lineTo(mX, mY);
        // commit the path to our offscreen
        mCanvas.drawPath(mPath, mPaint);
        // kill this so we don't double draw
        mPath = new Path();
        paths.add(mPath);
    }

    @Override
    public boolean onTouch(View arg0, MotionEvent event) {
        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // if (x &lt;= cx+circleRadius+5 &amp;&amp; x&gt;= cx-circleRadius-5) {
            // if (y&lt;= cy+circleRadius+5 &amp;&amp; cy&gt;= cy-circleRadius-5){
            // paths.clear();
            // return true;
            // }
            // }
            touch_start(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:
            touch_move(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            touch_up();
            invalidate();
            break;
        }
        return true;
    }
}

@Override
public void colorChanged(int color) {
    // TODO Auto-generated method stub
    PreferenceManager.getDefaultSharedPreferences(this).edit()
    .putInt(COLOR_PREFERENCE_KEY, color).commit();
    selectedColor = color;
}

@Override
public void colorChanged(int color, int bg) {
    // TODO Auto-generated method stub      
}
 }
</code></pre>
