如何获取捕获的图像文件路径并保存到数据库?

how to get Captured image filepath and save to database?

我想知道是否有人可以帮助我,我的应用程序当前使用多个捕获图像按钮拍照,我想获取每张图像的文件路径并将其保存到数据库中。我将如何去做这件事。我尝试使用 string name = fileuri.getpath 将其保存到我的数据库中,但这并没有给出拍摄图像的确切目的地。

else if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE_2) {

             if (resultCode == RESULT_OK) {

                String second_imagePath = fileUri.getPath();
                 BitmapFactory.Options options = new BitmapFactory.Options();
                 // down sizing image as it throws OutOfMemory Exception for larger
                 // images
                 options.inSampleSize = 8;
                 final Bitmap bitmap = BitmapFactory.decodeFile(second_imagePath, options);
                 second_image.setImageBitmap(bitmap);

                 Toast.makeText(getApplicationContext(),
                         second_imagePath, Toast.LENGTH_SHORT)
                         .show();

有一些步骤你需要遵循,你需要在打开意图之前传递图像名称

 String fileName = "some.jpg";  
 ContentValues values = new ContentValues();  
 values.put(MediaStore.Images.Media.TITLE, fileName);  
 mCapturedImageURI = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);  

 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
 intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);  
 startActivityForResult(intent, CAPTURE_PICTURE_INTENT);

然后 onActivityResult()

Cursor cursor = managedQuery(mCapturedImageURI, projection, null, null, null); 
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
cursor.moveToFirst(); 
String capturedImageFilePath = cursor.getString(column_index_data);