是否可以通过 Android 应用程序中的代码清除下载管理器应用程序数据
我想通过代码清除默认下载管理器应用程序的缓存和数据。是否可以?我需要这个,因为手动清除下载管理器数据可以让我的应用程序下载更成功。是否可以从我们的应用程序中删除其他应用程序的缓存或数据?
I would like to clear both cache and data of default download manager app through code. Is it possible? I need this because manually clearing download manager data is giving more successful downloads from my app. Is it possible to delete cache or data of other app from our application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 @Sergey Benner 的评论,遵循代码形式
blog.lytsing.org/archives/135.html 并从那里获取 getContentResolver().delete(Downloads.CONTENT_URI, "(" + Downloads.TITLE + " = 'screenshot')", null);
由于 android.provider.Downloads 是私有类,因此我们无法直接引用它,因此我用从类 https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/provider/Downloads.java
getContentResolver().delete(Uri.parse("content ://downloads/my_downloads"),"(" + "标题" + " = '您的下载标题')", null);
通过使用它,我可以从下载管理器中清除一些数据。
请注意,我将其应用到使用系统密钥签名的应用程序中。
from the comment of @Sergey Benner following the code form
blog.lytsing.org/archives/135.html and taken from there getContentResolver().delete(Downloads.CONTENT_URI, "(" + Downloads.TITLE + " = 'screenshot')", null);
As android.provider.Downloads is private class so we can not reference it directly, so I replaced the constants with strings taken from the class https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/provider/Downloads.java
getContentResolver().delete(Uri.parse("content://downloads/my_downloads"),"(" + "title" + " = 'Your download title')", null);
By using this I am able to clear some data from Download manager.
Please note I applied it in app signed with systems keys.