// 更新MediaStore中記錄的標(biāo)題和描述
ContentValues contentValues = new ContentValues(3);
contentValues.put(Media.DISPLAY_NAME,
titleEditText.getText().toString());
contentValues.put(Media.DESCRIPTION,
descriptionEditText.getText().toString());
getContentResolver().update(imageFileUri,contentValues,
null,null);
// 通知用戶
Toast bread = Toast.makeText(MediaStoreCameraIntent
this, "Record Updated", Toast.LENGTH_SHORT);
bread.show();
// 回到初始狀態(tài),設(shè)置拍照按鈕為可見
// 隱藏其他UI 元素
takePictureButton.setVisibility(View.VISIBLE);
returnedImageView.setVisibility(View.GONE);
saveDataButton.setVisibility(View.GONE);
titleTextView.setVisibility(View.GONE);
descriptionTextView.setVisibility(View.GONE);
titleEditText.setVisibility(View.GONE);
descriptionEditText.setVisibility(View.GONE);
}
});
}
當(dāng)Camera應(yīng)用程序返回一幅圖像時(shí),saveDataButton按鈕變得可見,其onClickListener事件完成將圖像與元數(shù)據(jù)相關(guān)聯(lián)的工作。它獲得用戶輸入到各個(gè)EditText元素中的值,并創(chuàng)建一個(gè)ContentValues對(duì)象,該對(duì)象用于更新MediaStore中關(guān)于該圖像的記錄。
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);