Android delete all files starting with particular word -


I have a problem and I hope you can help me.

In my wallpaper app, I am saving an image in the SDCard so that the user can share it online through the action share share function.

Here is the code that saves:

  URI bmpUri = null; {File file = new file (try the Environment GateInstinstoraz Public Directory (Environmental DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis () + ".png"); File.getParentFile () mkdirs () .; FileOutputStream Out = New FileOutputStream (File); Bmp.compress (bitmap.compress format.png, 90, out); Out.close (); BmpUri = Uri.framefile (file); } Hold (IOException e) {e.printStackTrace (); } Return BMPURI;  

Now, I am trying to remove the image when the user leaves the activity (meaning that he has already shared the image or did not decide to share / P>

I'm trying to remove it from this code (the click method on its button is ATM, but will change later)

  Case R.id.btn_delete : // file folder = (Environment.getExternalStoragePublicDirectory (environment. DIRECTORY_DOWNLOADS)); File folder = new file (environment .getExter NalStorageDirectory () + environment. DIRECTORY_DOWNLOADS); file [] filenamestemp = folder.listFiles (); for (int i = 0; i & lt; filenamestemp.length; i ++) {if (filenamestemp [i] .getAbsolutePath ( ToString (.) Includes ("share_image_") filenamestemp [i] .delete ();} breakdown;  

The way I see it, it should work ... but it is not.

I tried all kinds of things, but notes work.

No help>

I think you should find the wrong directory for written files. Brief are

You

  File Folder = new File (Environment .getExternalStorageDirectory () + environment. DIRECTORY_DOWNLOADS); Instead: 

  file folder = (environment. 


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -