Video thumbnails not refreshing

一曲冷凌霜 提交于 2020-01-06 07:32:13

问题


I am showing all available videos in a gridView on which are in SDCard by using following code.

String[] proj= {MediaStore.Video.Media._ID,MediaStore.Video.Media.DATA,MediaStore.Video.Media.DISPLAY_NAME,
                MediaStore.Video.Media.SIZE };
        videocursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null);

It is working fine... But if i made any changes to videos (i.e rename, delete) above code is not working. It is showing old content only, means not refreshing. How can i solve this problem


回答1:


what should do is the following :

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
            + Environment.getExternalStorageDirectory()))); 

right after your code .

provides a way for applications to pass a newly created or downloaded media file to the media scanner service.



来源:https://stackoverflow.com/questions/21303974/video-thumbnails-not-refreshing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!