title: Android setBitmap to canvas
body: <p>i want to convert canvas to image and save it on device. But when I set bitmap to canvas I get error <code>java.lang.UnsupportedOperationException</code>.
  My full code:</p>
  
  <pre><code>public class SingleTouchEventView extends View {
  private Paint paint = new Paint();
  private Path path = new Path();
  
  
  public SingleTouchEventView(Context context, AttributeSet attrs) {
      super(context, attrs);
  
      paint.setAntiAlias(true);
      paint.setStrokeWidth(6f);
      paint.setColor(Color.WHITE);
      paint.setStyle(Paint.Style.STROKE);
      paint.setStrokeJoin(Paint.Join.BEVEL);
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      canvas.drawPath(path, paint);
      canvas.drawCircle(50, 50, 3, paint);
      Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
      canvas.setBitmap(bitmap);
      try {
  
          File file = new File(Environment.getExternalStorageDirectory() + "/image.jpg");
          bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(file));
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Maybe someone could help me to solve this problem?</p>