Directory tree picker created by
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
...
on Android 5+ saves all picked directories history to the Recent
folder:
...
Is there a way how to erase this history?
The recents history is saved in a database which is located:
/data/data/com.android.documentsui/databases/recents.db
So it's not accessible to the other apps, unless the device is rooted.
There is a ContentProvider
(RecentsProvider) that manages the database but unfortunately it isn't exported, so only applications that have the same user ID (UID) as the provider will have access to it [1].
There is also a BroadcastReceiver
(PackageReceiver) that controls the ContentProvider
and purge the recents but unfortunately it only receives ACTION_PACKAGE_FULLY_REMOVED
[2] and ACTION_PACKAGE_DATA_CLEARED
[3]. Both the intent are protected and they can only be sent by the system.
tl;dr Unfortunately you can't clean the recents. The only viable solution is to clear the whole data of Documents app, but in this case every settings will be lost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With