0

I tried code from this record sound. I see that I can release sound using the following code:

private void stopPlaying() {  
    mPlayer.release();  
    mPlayer = null;  
}

The problem is that I want to release the sound and delete the recorded file. if only use this code I still have the sound file on mFileName with file name is audiorecordtest.3gp.

Anyone know how to delete this file so I can save memory on my phone ?

bvt19
  • 19
  • 1
  • 5
gondai yosuke
  • 599
  • 2
  • 5
  • 19

1 Answers1

0

just try this code,

  File f1 = new File(mFileName);
  boolean success = f1.delete();
  if (!success){
    Toast.makeText(getApplicationContext(), "File not deleted!", Toast.LENGTH_LONG).show();
  }
  else
  {
    Toast.makeText(getApplicationContext(), "File deleted.", Toast.LENGTH_LONG).show();
  }
Stack Overflow User
  • 4,052
  • 6
  • 29
  • 47