When deleting gallery photo the file still exists in the gallery without image

Asked

Viewed 27 times

2

I’m trying to delete a photo gallery via code by android studio. After the execution of the code the photo file still remains there without the image containing an exclamation as image. The name, size and details still continue, see the code::

File imagem = new File(v_CaminhoFoto + "/" + v_nome_foto);
imagem.delete();

It seems to me that he is only cleaning the photo bitmap and preserving the file.

Android manifest this already:

uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  • 1

    This happens because the Gallery is only updated, by the Android OS, from time to time. See if this reply solves the problem.

  • 1

    See also if this answer solves the problem.

  • Really, thanks for your help. This simple code updates the gallery: // updates gallery to this deleted file sendBroadcast(New Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(v_CaminhoFoto + "/" + v_foto))));

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.