1

I would really like your help in knowing the procedure to delete a .3gp file that has been recorded and stored.

Currently the common file.delete() command does not physically delete the file and we don't even receive an error message displaying why the file deletion was not successful. As per the command it has been executed successfully but the file is remaining intact in the external storage directory.

Can anyone help me with some explanation why this is happening and a solution to solve this issue.

Awaiting your early replies.

kaiz.net
  • 1,984
  • 3
  • 23
  • 31
Jay Nag
  • 13
  • 3

1 Answers1

3

simply

File file = new File(filePath);

    try                                    
    {

      if(file.exists())
      {
         file.delete();
      } 


    }

    catch (IOException e) 
    {
       e.printStackTrace();
    }

dont forget to add permissions in manifest

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
vipin
  • 2,851
  • 4
  • 18
  • 32
  • Thanks Michal for your early response. Tried your code with the permissions, but still the file is existing and not getting deleted. I am trying this on a Android Tablet. Is there any seperate permission for tablets. – Jay Nag Mar 26 '12 at 13:19
  • are you giving full name with extention – vipin Mar 26 '12 at 13:27
  • Thanks a lot Vipin for you reply. Yes there was a problem in the path given, the file name was full with extension. Due to this the deletion was failing. Thanks to all your help, I am really happy that I could get the response so fast and so accurate. Thanks everyone and thanks StackOverFlow. – Jay Nag Mar 27 '12 at 06:05