[英]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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.