I am trying following code
String Data = cursor.getString(cursor
.getColumnIndex(MediaStore.Audio.Media.DATA));
File file = new File(Data);
if (file != null && file.exists()) {
// delete it
Toast.makeText(FileEditorDialog.this, "deleted not null",
Toast.LENGTH_LONG).show();
}
boolean deleted = file.delete();
if (deleted) {
Toast.makeText(FileEditorDialog.this,
"Successfully Deleted", Toast.LENGTH_LONG).show();
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
finish();
}
This code works in Android jelly bean but not in Android lollipop how can we delete files in Android lollipop?