0

I'm trying to delete an image from my gallery:

 file.delete()

and the file was not completely deleted - when I check if the file exists:

 file.exists()

It return false but if I get into the gallery I can see that instead the image there is an empty image (like an error). But if I restarting my device the image completely delete! so my question is: How can I refresh the gallery?

madhan kumar
  • 1,560
  • 2
  • 26
  • 36
PHPupil
  • 785
  • 1
  • 7
  • 10
  • 1
    file should be used by another process therefore it is not deleted.... – Developer Desk Oct 25 '14 at 09:10
  • What boolean value does `delete()` return for you? – TarasB Oct 25 '14 at 09:12
  • @Sumit so what should I do? – PHPupil Oct 25 '14 at 09:12
  • @Taras B it returns "true" – PHPupil Oct 25 '14 at 09:14
  • @PHPupil if it gives `true` then the image is truly deleted. The thing now is how Gallery app reacts on that. Check here http://stackoverflow.com/questions/22606080/how-to-refresh-gallery-after-deleting-image-from-sdcard how people propagate the change to media apps. – TarasB Oct 25 '14 at 09:17
  • @Taras It doesnt work for me.. – PHPupil Oct 25 '14 at 09:35
  • The file is completely deleted ofcourse. Not partially. But Gallery app uses a thumbnail generated by the media store. So only when the media store is aware of a file delete it will not show the picture anymore. This is for instance after a reboot. – greenapps Oct 25 '14 at 10:48
  • @greenapps i understand, there is more actions for "media store is aware of a file delete it will not show the picture anymore"? – PHPupil Oct 25 '14 at 10:57

1 Answers1

0

I work in my computer,there is not this problem,when i use file.delete(), the file can be completely deleted. And my environment is jdk 1.7_0_51. so i think it's maybe a version error

  • no.. my environment is jdk 1.8_0_20.. maybe i will try my app with another device (with another android version).. @Peng Zhang – PHPupil Oct 25 '14 at 10:13