Remove audio file that is existing on the device - Android android.media

Android examples for android.media:Audio

Description

Remove audio file that is existing on the device

Demo Code

import android.content.Context;
import android.net.Uri;

public class Main {

  /****//from  w w  w. j av a  2 s .c om
   * Remove audio file that is existing on the device.
   * 
   * @param ctx
   *          {@link Context}
   * @param uri
   *          {@link Uri} of the audio file
   * 
   * @throws NullPointerException
   *           if the Uri parameter is null
   */
  public static boolean removeAudio(Context ctx, Uri uri) {

    if (uri == null) {
      throw new NullPointerException("Uri cannot be null");
    }

    return (ctx.getContentResolver().delete(uri, null, null) != 0);
  }

}

Related Tutorials