protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode)
{
case TAKE_IMAGE:
try {
if (resultCode == RESULT_OK) {
// we need to update the gallery by starting MediaSanner service.
mScanner = new MediaScannerConnection(ProfilePicFromCamera.this,new MediaScannerConnection.MediaScannerConnectionClient()
{
public void onMediaScannerConnected() {
mScanner.scanFile(imageUri.getPath(),null /*mimeType*/);
}
public void onScanCompleted(String path, Uri uri) {
if (path.equals(imageUri.getPath())) {
mScanner.disconnect();
ProfilePicFromCamera.this.runOnUiThread(new Runnable() {
public void run() {
updateUI();
}
});
}
}
});
mScanner.connect();
}
} catch (Exception e) {
e.printStackTrace();
}
break;
case UPLOAD_IMAGES:
if(resultCode==RESULT_OK)
{
if(file.exists())
file.deleteOnExit();
}
break; }
}
问问题
334 次
3 回答
2
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == getActivity().RESULT_OK) {
File file = new File(mCapturedImagePath);
file.delet();
}
}
or u can use only this(as your condition)
File file = new File(mCapturedImagePath);
file.delet();
于 2013-03-29T06:16:48.333 回答
0
使用下面的代码它可以帮助你。
File fdelete = new File(file_dj_path);
if (fdelete.exists()) {
if (fdelete.delete()) {
System.out.println("file Deleted :" + file_dj_path);
} else {
System.out.println("file not Deleted :" + file_dj_path);
}
}
下面是删除图像后刷新图库的代码
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
于 2013-03-29T06:49:28.217 回答
0
File file = new File(Environment.getExternalStorageDirectory()+"image_name"); //if your image is directly inside sdcard
file.delete();
于 2013-03-29T06:17:22.600 回答