0

I am trying to delete a file located at the path

"/sdcard/Download/images.jpg"

What I've done so far:

try{
        File file = new File("/sdcard/Download/images.jpg");
        if(file.exists())
        { deleted = file.delete();
        Toast.makeText(getApplicationContext(), "File Deleted "+deleted,Toast.LENGTH_LONG ).show();
        }
        else
            Toast.makeText(getApplicationContext(), "File Not Deleted "+deleted,Toast.LENGTH_LONG ).show();
    }catch(Exception e){
        e.printStackTrace();


    }

Now I'm getting a toast message:

File Deleted false

and the file is still at its place(Not deleted :( ) Also I've given android.permission.WRITE_EXTERNAL_STORAGE in Manifest file.

saurabh gupta
  • 491
  • 6
  • 18

0 Answers0