简体   繁体   English

Android 如何从我的设备手机中的图库中删除图像

[英]Android how to delete image from gallery in my device phone

I want user click action delete image and image will be deleted in gallery.我希望用户单击操作删除图像,图像将在图库中删除。 How to delete image in gallery from my phone.如何从我的手机中删除图库中的图像。 I have tried all code in this link stackoverflow but still can't delete image in gallery from my device phone android: deleting an image How to delete a file from Gallery in Android?我已经尝试了此链接 stackoverflow 中的所有代码,但仍然无法从我的设备手机android 中删除图库中的图像:删除图像如何从 Android 中的图库中删除文件? How to delete an image from device in Android programmatically? 如何以编程方式从 Android 中的设备中删除图像?

Try this:尝试这个:

File fdelete = new File(uri.getPath());
if (fdelete.exists()) {
    if (fdelete.delete()) {
        System.out.println("file Deleted :" + uri.getPath());
    } else {
        System.out.println("file not Deleted :" + uri.getPath());
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM