0
			mCamera = Camera.open();
			mCamera.unlock();
		} 
 
		if(mMediaRecorder == null)
			mMediaRecorder = new MediaRecorder();
		mMediaRecorder.setPreviewDisplay(surface);
		mMediaRecorder.setCamera(mCamera);
		 
		mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
		mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
		File file = new File(Environment.getExternalStorageDirectory(),VIDEO_PATH_NAME);
		// "touch" the file 
		if(!file.exists()) {
			File parent = file.getParentFile();
			if(parent != null) 
				if(!parent.exists())
					if(!parent.mkdirs())
						throw new IOException("Cannot create " +
								"parent directories for file: " + file);
			 
				file.createNewFile();
		} 
		 
		mMediaRecorder.setOutputFile(file.getAbsolutePath());
		 
		// No limit. Check the space on disk! 
		mMediaRecorder.setMaxDuration(-1);
		mMediaRecorder.setVideoFrameRate(15);
		 
		mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
		 
		try { 
			mMediaRecorder.prepare();
		} catch (IllegalStateException e) {
			// This is thrown if the previous calls are not called with the  
			// proper order 
			e.printStackTrace();
		} 
Stop searching for code, let great code find you!  Add Codota to your java IDE