application stopped while saving fingerpaint image in android
===

Hey I want to save the image made by user in fingerpaint API through the save menu. But when I clicked on save option, my application stopped<br>Here is activity class `
       
   

     public class WriteOnScreenActivityActivity extends Activity {
        public TouchEventView touchview;
        public int mImageCount = 0;
                      
        /** Called when the activity is first created. */
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    		Button res = (Button) findViewById(R.id.reset);
    		res.setOnClickListener(new View.OnClickListener() {
    
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				TouchEventView touchView = (TouchEventView) findViewById(R.id.mydrawview1);
    				touchView.clear();
    
    			}
    		});
    
    	}
    
    	@Override
    	public boolean onCreateOptionsMenu(Menu menu) {
    		MenuInflater inflater = getMenuInflater();
    		inflater.inflate(R.menu.menu_name, menu);
    		return true;
    	}
    
    	@Override
    	public boolean onOptionsItemSelected(MenuItem item) {
    		switch (item.getItemId()) {
    		case R.id.save:
    			save();
    			return true;
    		case R.id.open:
    			open();
    			return true;
    		default:
    			return super.onOptionsItemSelected(item);
    
    		}
    
    	}
    
    	public void save() {
    		File myDir = new File("/sdcard/saved_images");
    		myDir.mkdirs();
    		mImageCount++;
    		String fname = "image-" + mImageCount + ".jpg";
    		File file = new File(myDir, fname);
    		if (file.exists())
    			file.delete();
    		touchview.saveAsJpg(file);
    	}
    
    	public void open() {
    		TextView tv = new TextView(this);
    		tv.setText("Hello, Android");
    		setContentView(tv);
    
    	}
    
    }

` 
Here is View class

        public class TouchEventView extends View {
    	private static Bitmap mBitmap;
    
    	private Paint paint = new Paint();
    	private Path path = new Path();
    
    	public TouchEventView(Context context, AttributeSet attrs) {
    		super(context, attrs);
    
    		paint.setAntiAlias(true);
    		paint.setColor(Color.WHITE);
    		paint.setStyle(Paint.Style.STROKE);
    		paint.setStrokeJoin(Paint.Join.ROUND);
    		paint.setStrokeWidth(5f);
    	}
    
    	@Override
    	protected void onDraw(Canvas canvas) {
    		canvas.drawPath(path, paint);
    	}
    
    	public void clear() {
    		path = new Path();
    		invalidate();
    	}
    
    	@Override
    	public boolean onTouchEvent(MotionEvent event) {
    		float eventX = event.getX();
    		float eventY = event.getY();
    
    		switch (event.getAction()) {
    		case MotionEvent.ACTION_DOWN:
    			path.moveTo(eventX, eventY);
    
    			return true;
    		case MotionEvent.ACTION_MOVE:
    			path.lineTo(eventX, eventY);
    			break;
    		case MotionEvent.ACTION_UP:
    			// nothing to do
    			break;
    		default:
    			return false;
    		}
    
    		// Schedules a repaint.
    		invalidate();
    		return true;
    	}
    
    	public void saveAsJpg(File f) {
    		String fname = f.getAbsolutePath();
    		FileOutputStream fos = null;
    		try {
    			fos = new FileOutputStream(f);
    			// Take the bitmap of the view and write it out as a jpeg.
    			mBitmap.compress(CompressFormat.JPEG, 95, fos);
    		} catch (Throwable ex) {
    
    		}
    	}
    }

` Here is Logcat

    07-10 00:37:51.494: E/AndroidRuntime(570): FATAL EXCEPTION: main
    07-10 00:37:51.494: E/AndroidRuntime(570): java.lang.NullPointerException
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at de.vogella.android.touch.WriteOnScreenActivityActivity.onOptionsItemSelected(WriteOnScreenActivityActivity.java:55)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.app.Activity.onMenuItemSelected(Activity.java:2502)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:950)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:81)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.widget.AdapterView.performItemClick(AdapterView.java:292)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.widget.AbsListView$1.run(AbsListView.java:3168)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.os.Handler.handleCallback(Handler.java:605)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.os.Handler.dispatchMessage(Handler.java:92)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.os.Looper.loop(Looper.java:137)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at android.app.ActivityThread.main(ActivityThread.java:4424)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at java.lang.reflect.Method.invokeNative(Native Method)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at java.lang.reflect.Method.invoke(Method.java:511)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    07-10 00:37:51.494: E/AndroidRuntime(570): 	at dalvik.system.NativeStart.main(Native Method)
    `
Why this error is coming? Do tell me. Thanks for your help