請問繪圖程式如何加程式碼變成有儲存功能能儲存檔案

 請問高手們     如何在下面那段程式碼有儲存檔案的功能

    private PaintmPaint;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(new TouchView(this));

 

        mPaint = new Paint();

        mPaint.setAntiAlias(true);

        mPaint.setDither(true);

        mPaint.setColor(0xff00ff00);

        mPaint.setStyle(Paint.Style.STROKE);

        mPaint.setStrokeJoin(Paint.Join.ROUND);

        mPaint.setStrokeCap(Paint.Cap.ROUND);

        mPaint.setStrokeWidth(5);       

    }

        

    public class TouchView extends View {

               

        private Bitmap  mBitmap;

        private Canvas  mCanvas;

        private Path    mPath;

        private Paint   mBitmapPaint;

        

        public TouchView(Context c) {

            super(c);

            

            mBitmap = Bitmap.createBitmap(640, 960, 

             Bitmap.Config.ARGB_4444);

            mCanvas = new Canvas(mBitmap);

            mPath = new Path();

            mBitmapPaint = new Paint(Paint.DITHER_FLAG);

        }

        

        @Override

        protected void onDraw(Canvas canvas) {            

            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);            

            canvas.drawPath(mPath, mPaint);

        }

        

        private float mX, mY;

        private static final float TOUCH_TOLERANCE = 4;

        

        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 >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {

                mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);

                mX = x;

                mY = y;

            }

        }

        private void touch_up() {

            mPath.lineTo(mX, mY);

            mCanvas.drawPath(mPath, mPaint);

            mPath.reset();

        }

        

        @Override

        public boolean onTouchEvent(MotionEvent event) {

            float x = event.getX();

            float y = event.getY();

            

            switch (event.getAction()) {

                case MotionEvent.ACTION_DOWN:

                    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;

        }

    }       

}