捕获的图像存储在SD卡中,并且用于从sdcard查看数据,路径名称存储在数据库中。但有时路径在db中被保存为NULL。
// click on camera
takePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// take pic
if((takePicRedBtn.isChecked())) {
captureImage();//capture image
}});
}
//capturing image
private void captureImage() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}
// inside on Activity Result
if(requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE)
{
if (resultCode == Activity.RESULT_OK) {
// successfully captured the image
//here i insert path name into db
takePicIntoDb();
}