Android ACTION_GET_CONTENT does not update downloa

2019-04-05 11:21发布

问题:

I am facing an issue while choosing a file from Downloads directory using ACTION_GET_CONTENT.

If I delete any file in ES explorer or file manager in my local storage, those deleted files aren't removed in downloads dir while opening in my app.

Any changes in downloads dir dosen't get reflected in chooser.

To choose a file I am using the below library

https://github.com/iPaulPro/aFileChooser.

Here I attach my screenshot please have a look:

回答1:

You must have to call getContentResolver().delete(uri, null, null) while deleting the file, where uri is the URI of the file to delete. This will update Media Store, which holds URIs of all files. So, when ACTION_GET_CONTENT opens the downloads directory, the file you deleted won't appear here.