4

I use MediaStore to get all video files from Android device. Then I delete some of these videos. Followed I use MediaStore again, and I get all deleted files.

Why MediaStore returns files that are no longer are on the device?

Delete File:

File file = new File(filePath);
file.delete();

Get all video files from device:

public static List<String> getVideoFiles(Context context) {

String[] projection = { MediaStore.Video.Media.DATA };

Cursor cursor = context.getContentResolver().query(
        MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null,
        null, null);

List<String> videoList = new ArrayList<String>();
while (cursor.moveToNext()) {
    videoList.add(cursor.getString(0));

}

Log.i(Constants.LOG_TAG, "get video files, load: " + videoList.size() + " "
        + videoList.toString());

return videoList;
}
user3782779
  • 1,669
  • 3
  • 22
  • 36

1 Answers1

1

MediaStore updates the list of media is not in real time. It needed time to test the relevance of its database. Try to make a call MediaStore after some time. Or report manually about updating content.

Community
  • 1
  • 1
user2413972
  • 1,355
  • 2
  • 9
  • 25