Save Camera Pic in android


private void startCameraForCapture() {

// create Intent to take a picture and return control to the calling
// application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

try {

String path = Environment.getExternalStorageDirectory()+ File.separator + "/CameraImages/example.jpg";

File file = new File(path);
Uri outputFileUri = Uri.fromFile(file);
System.out.println("path is " + Uri.fromFile(file).getEncodedPath());
intent.putExtra(MediaStore.EXTRA_OUTPUT, file); // set the image
// file name

// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY);

} catch (Exception e) {
// TODO Auto-generated catch block

// _errorMessageTitle = "Error 'StartCamera'";

// _errorMessage = "Error: " + e.toString();

// showDialog(DIALOG_ERROR_GENERAL);

}

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == CAPTURE_IMAGE_ACTIVITY) {

if (resultCode == RESULT_OK) {

// showPhoto(2);

System.out.println("My Photos...................");

} else if (resultCode == RESULT_CANCELED) {

// User cancelled the image capture

} else {

// Image capture failed, advise user
// _errorMessageTitle = "Error in 'Take Photo'";

// / _errorMessage = "Image Capture Failed";

// showDialog(DIALOG_NOTICE_GENERAL);

}

}


}