我试图创建一个基本上拍照并将其保存在我已经创建的文件夹中的应用程序,但是当我检查文件夹时,它是空的。有没有办法检查我的文件是否真的被保存了? 这是我的代码:
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
filePathTop = "/TopClothes/Image_" + timeStamp + ".jpg" ;
//filePathBot = "/BottomClothes/Image_" + timeStamp + ".png" ;
File foldertop = new File(Environment.getExternalStorageDirectory() + "/TopClothes");
File folderbot = new File(Environment.getExternalStorageDirectory() + "/BottomClothes");
File image = new File(foldertop, "Image_" + timeStamp + ".jpg");
uriSavedImage = Uri.fromFile(image);
boolean success = true;
if (!foldertop.exists()) {
success = foldertop.mkdir();
}
然后:
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bCamera:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
i.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
break;
}
}
答案 0 :(得分:0)
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bCamera:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
startActivityForResult(i, cameraData);
break;
}
}
尝试在开始活动之前放置图片uri