Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaStore show files after deleted

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;
}
like image 775
user3782779 Avatar asked Dec 21 '25 13:12

user3782779


1 Answers

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.

like image 138
user2413972 Avatar answered Dec 23 '25 02:12

user2413972



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!