I try to delete a file using contentResolver but only delete the entry from database, not the real file. So I try delete first the entry and later the file:
int rows = context.getContentResolver().delete(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
MediaStore.Audio.Media._ID + "=" + idSong, null);
// Remove file from card
if (rows != 0) {
Uri uri = ContentUris.withAppendedId(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, idSong);
File f = new File(uri.getPath());
if(!f.delete())
Log.d("fail-2", "fail-2");
}
else
Log.d("fail-1", "fail-1");
...and the output is "fail-2". Why?
Why ContentResolver doesn't delete the real file? Is this normal?