I am trying to delete a file using contentResolver, but only delete the record from the database, not the real file. So I will try to delete the record first and then 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 doesn't ContentResolver delete the real file? This is normal?
source share